Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: lpfc: remove null check on nvmebuf

The null checks on nvmebuf are redundant as nvmebuf is always obtained from
a container_of() and hence can never be null. Remove all the redundant null
checks. This also cleans up a static analysis warning.

Detected by CoverityScan, CID#1471753 ("Dereference before null check")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Colin Ian King and committed by
Martin K. Petersen
cc74e31d a5445238

+3 -5
+3 -5
drivers/scsi/lpfc/lpfc_nvmet.c
··· 1745 1745 fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt); 1746 1746 oxid = be16_to_cpu(fc_hdr->fh_ox_id); 1747 1747 1748 - if (!nvmebuf || !phba->targetport) { 1748 + if (!phba->targetport) { 1749 1749 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 1750 1750 "6154 LS Drop IO x%x\n", oxid); 1751 1751 oxid = 0; ··· 1770 1770 lpfc_nvmeio_data(phba, "NVMET LS DROP: " 1771 1771 "xri x%x sz %d from %06x\n", 1772 1772 oxid, size, sid); 1773 - if (nvmebuf) 1774 - lpfc_in_buf_free(phba, &nvmebuf->dbuf); 1773 + lpfc_in_buf_free(phba, &nvmebuf->dbuf); 1775 1774 return; 1776 1775 } 1777 1776 ctxp->phba = phba; ··· 1813 1814 ctxp->oxid, rc); 1814 1815 1815 1816 /* We assume a rcv'ed cmd ALWAYs fits into 1 buffer */ 1816 - if (nvmebuf) 1817 - lpfc_in_buf_free(phba, &nvmebuf->dbuf); 1817 + lpfc_in_buf_free(phba, &nvmebuf->dbuf); 1818 1818 1819 1819 atomic_inc(&tgtp->xmt_ls_abort); 1820 1820 lpfc_nvmet_unsol_ls_issue_abort(phba, ctxp, sid, oxid);