Skip to content

Commit f31ba0f

Browse files
Harsh Jainherbertx
authored andcommitted
crypto: chelsio - Fix wrong error counter increments
Fix error counter increment in AEAD decrypt operation when validation of tag is done in Driver instead of H/W. Signed-off-by: Harsh Jain <harsh@chelsio.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 6501ab5 commit f31ba0f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

drivers/crypto/chelsio/chcr_algo.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static inline void chcr_dec_wrcount(struct chcr_dev *dev)
218218
atomic_dec(&dev->inflight);
219219
}
220220

221-
static inline void chcr_handle_aead_resp(struct aead_request *req,
221+
static inline int chcr_handle_aead_resp(struct aead_request *req,
222222
unsigned char *input,
223223
int err)
224224
{
@@ -233,6 +233,8 @@ static inline void chcr_handle_aead_resp(struct aead_request *req,
233233
}
234234
chcr_dec_wrcount(dev);
235235
req->base.complete(&req->base, err);
236+
237+
return err;
236238
}
237239

238240
static void get_aes_decrypt_key(unsigned char *dec_key,
@@ -2072,14 +2074,13 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
20722074

20732075
switch (tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
20742076
case CRYPTO_ALG_TYPE_AEAD:
2075-
chcr_handle_aead_resp(aead_request_cast(req), input, err);
2077+
err = chcr_handle_aead_resp(aead_request_cast(req), input, err);
20762078
break;
20772079

20782080
case CRYPTO_ALG_TYPE_ABLKCIPHER:
2079-
err = chcr_handle_cipher_resp(ablkcipher_request_cast(req),
2081+
chcr_handle_cipher_resp(ablkcipher_request_cast(req),
20802082
input, err);
20812083
break;
2082-
20832084
case CRYPTO_ALG_TYPE_AHASH:
20842085
chcr_handle_ahash_resp(ahash_request_cast(req), input, err);
20852086
}

drivers/crypto/chelsio/chcr_core.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,18 @@ static int cpl_fw6_pld_handler(struct chcr_dev *dev,
169169

170170
ack_err_status =
171171
ntohl(*(__be32 *)((unsigned char *)&fw6_pld->data[0] + 4));
172-
if (ack_err_status) {
173-
if (CHK_MAC_ERR_BIT(ack_err_status) ||
174-
CHK_PAD_ERR_BIT(ack_err_status))
175-
error_status = -EBADMSG;
176-
atomic_inc(&adap->chcr_stats.error);
177-
}
172+
if (CHK_MAC_ERR_BIT(ack_err_status) || CHK_PAD_ERR_BIT(ack_err_status))
173+
error_status = -EBADMSG;
178174
/* call completion callback with failure status */
179175
if (req) {
180176
error_status = chcr_handle_resp(req, input, error_status);
181177
} else {
182178
pr_err("Incorrect request address from the firmware\n");
183179
return -EFAULT;
184180
}
181+
if (error_status)
182+
atomic_inc(&adap->chcr_stats.error);
183+
185184
return 0;
186185
}
187186

0 commit comments

Comments
 (0)