* [PATCH] crypto: marvell/octeontx - Fix a potential NULL dereference
@ 2020-06-05 11:03 Dan Carpenter
2020-06-12 6:48 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-06-05 11:03 UTC (permalink / raw)
To: Boris Brezillon, SrujanaChalla
Cc: Arnaud Ebalard, Srujana Challa, Herbert Xu, David S. Miller,
Lukasz Bartosik, linux-crypto, kernel-janitors
Smatch reports that:
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c:132 otx_cpt_aead_callback()
warn: variable dereferenced before check 'cpt_info' (see line 121)
This function is called from process_pending_queue() as:
drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c
599 /*
600 * Call callback after current pending entry has been
601 * processed, we don't do it if the callback pointer is
602 * invalid.
603 */
604 if (callback)
605 callback(res_code, areq, cpt_info);
It does appear to me that "cpt_info" can be NULL so this could lead to
a NULL dereference.
Fixes: 10b4f09491bf ("crypto: marvell - add the Virtual Function driver for CPT")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
index 60e744f680d34..1e0a1d70ebd39 100644
--- a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
struct otx_cpt_req_info *cpt_req;
struct pci_dev *pdev;
+ if (!cpt_info)
+ goto complete;
+
cpt_req = cpt_info->req;
if (!status) {
/*
@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
!cpt_req->is_enc)
status = validate_hmac_cipher_null(cpt_req);
}
- if (cpt_info) {
- pdev = cpt_info->pdev;
- do_request_cleanup(pdev, cpt_info);
- }
+ pdev = cpt_info->pdev;
+ do_request_cleanup(pdev, cpt_info);
+
+complete:
if (areq)
areq->complete(areq, status);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: marvell/octeontx - Fix a potential NULL dereference
2020-06-05 11:03 [PATCH] crypto: marvell/octeontx - Fix a potential NULL dereference Dan Carpenter
@ 2020-06-12 6:48 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2020-06-12 6:48 UTC (permalink / raw)
To: Dan Carpenter
Cc: Boris Brezillon, SrujanaChalla, Arnaud Ebalard, David S. Miller,
Lukasz Bartosik, linux-crypto, kernel-janitors
On Fri, Jun 05, 2020 at 02:03:39PM +0300, Dan Carpenter wrote:
> Smatch reports that:
>
> drivers/crypto/marvell/octeontx/otx_cptvf_algs.c:132 otx_cpt_aead_callback()
> warn: variable dereferenced before check 'cpt_info' (see line 121)
>
> This function is called from process_pending_queue() as:
>
> drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c
> 599 /*
> 600 * Call callback after current pending entry has been
> 601 * processed, we don't do it if the callback pointer is
> 602 * invalid.
> 603 */
> 604 if (callback)
> 605 callback(res_code, areq, cpt_info);
>
> It does appear to me that "cpt_info" can be NULL so this could lead to
> a NULL dereference.
>
> Fixes: 10b4f09491bf ("crypto: marvell - add the Virtual Function driver for CPT")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/crypto/marvell/octeontx/otx_cptvf_algs.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-12 6:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 11:03 [PATCH] crypto: marvell/octeontx - Fix a potential NULL dereference Dan Carpenter
2020-06-12 6:48 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).