Skip to content

Commit 1f5b07f

Browse files
Dan Carpenterherbertx
authored andcommitted
crypto: marvell/octeontx - Fix a potential NULL dereference
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: 10b4f09 ("crypto: marvell - add the Virtual Function driver for CPT") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 77251e4 commit 1f5b07f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/crypto/marvell/octeontx/otx_cptvf_algs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
118118
struct otx_cpt_req_info *cpt_req;
119119
struct pci_dev *pdev;
120120

121+
if (!cpt_info)
122+
goto complete;
123+
121124
cpt_req = cpt_info->req;
122125
if (!status) {
123126
/*
@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
129132
!cpt_req->is_enc)
130133
status = validate_hmac_cipher_null(cpt_req);
131134
}
132-
if (cpt_info) {
133-
pdev = cpt_info->pdev;
134-
do_request_cleanup(pdev, cpt_info);
135-
}
135+
pdev = cpt_info->pdev;
136+
do_request_cleanup(pdev, cpt_info);
137+
138+
complete:
136139
if (areq)
137140
areq->complete(areq, status);
138141
}

0 commit comments

Comments
 (0)