Commit 1f5b07f5 authored by Dan Carpenter's avatar Dan Carpenter Committed by Herbert Xu

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: 10b4f094 ("crypto: marvell - add the Virtual Function driver for CPT")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 77251e41
...@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2) ...@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
struct otx_cpt_req_info *cpt_req; struct otx_cpt_req_info *cpt_req;
struct pci_dev *pdev; struct pci_dev *pdev;
if (!cpt_info)
goto complete;
cpt_req = cpt_info->req; cpt_req = cpt_info->req;
if (!status) { if (!status) {
/* /*
...@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2) ...@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
!cpt_req->is_enc) !cpt_req->is_enc)
status = validate_hmac_cipher_null(cpt_req); status = validate_hmac_cipher_null(cpt_req);
} }
if (cpt_info) { pdev = cpt_info->pdev;
pdev = cpt_info->pdev; do_request_cleanup(pdev, cpt_info);
do_request_cleanup(pdev, cpt_info);
} complete:
if (areq) if (areq)
areq->complete(areq, status); areq->complete(areq, status);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment