From: James Smart <james.smart@broadcom.com>
To: Colin King <colin.king@canonical.com>,
Dick Kennedy <dick.kennedy@broadcom.com>,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: lpfc: don't dereference dma_buf->iocbq before null check
Date: Sat, 4 Mar 2017 09:42:45 -0800 [thread overview]
Message-ID: <c7423fa3-299b-c010-bf4e-c34a11c146d3@broadcom.com> (raw)
In-Reply-To: <20170224140914.6011-1-colin.king@canonical.com>
Looks good. I included it in the lpfc patch set just posted.
-- james
On 2/24/2017 6:09 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> dma_buf->iocbq is being dereferenced immediately before it is
> being null checked, so we have a potential null pointer dereference
> bug. Fix this by only dereferencing it only once we have passed
> a null check on the pointer.
>
> Detected by CoverityScan, CID#1411652 ("Dereference before null check")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/scsi/lpfc/lpfc_mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
> index c61d8d6..5986c79 100644
> --- a/drivers/scsi/lpfc/lpfc_mem.c
> +++ b/drivers/scsi/lpfc/lpfc_mem.c
> @@ -646,7 +646,6 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
> }
>
> dma_buf->iocbq = lpfc_sli_get_iocbq(phba);
> - dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
> if (!dma_buf->iocbq) {
> kfree(dma_buf->context);
> pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt,
> @@ -658,6 +657,7 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
> "2621 Ran out of nvmet iocb/WQEs\n");
> return NULL;
> }
> + dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
> nvmewqe = dma_buf->iocbq;
> wqe = (union lpfc_wqe128 *)&nvmewqe->wqe;
> /* Initialize WQE */
prev parent reply other threads:[~2017-03-04 17:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 14:09 Colin King
2017-03-04 17:42 ` James Smart [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7423fa3-299b-c010-bf4e-c34a11c146d3@broadcom.com \
--to=james.smart@broadcom.com \
--cc=colin.king@canonical.com \
--cc=dick.kennedy@broadcom.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®