From patchwork Fri Jul 13 08:39:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10522795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A45A86028E for ; Fri, 13 Jul 2018 08:40:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95E9A2993D for ; Fri, 13 Jul 2018 08:40:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 899F029949; Fri, 13 Jul 2018 08:40:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37B7A2993D for ; Fri, 13 Jul 2018 08:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbeGMIxh (ORCPT ); Fri, 13 Jul 2018 04:53:37 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58518 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbeGMIxh (ORCPT ); Fri, 13 Jul 2018 04:53:37 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fdtcI-0000z1-Ty; Fri, 13 Jul 2018 08:39:54 +0000 From: Colin King To: James Smart , Dick Kennedy , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][V2] scsi: lpfc: remove null check on nvmebuf Date: Fri, 13 Jul 2018 09:39:54 +0100 Message-Id: <20180713083954.26877-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King 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 --- V2: Remove null pointer checks thanks to James Bottomley for spotting that the caller obtains nvmebuf from container_of(). --- drivers/scsi/lpfc/lpfc_nvmet.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 22f8a204b69f..b766afe10d3d 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -1745,7 +1745,7 @@ lpfc_nvmet_unsol_ls_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt); oxid = be16_to_cpu(fc_hdr->fh_ox_id); - if (!nvmebuf || !phba->targetport) { + if (!phba->targetport) { lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, "6154 LS Drop IO x%x\n", oxid); oxid = 0; @@ -1770,8 +1770,7 @@ lpfc_nvmet_unsol_ls_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, lpfc_nvmeio_data(phba, "NVMET LS DROP: " "xri x%x sz %d from %06x\n", oxid, size, sid); - if (nvmebuf) - lpfc_in_buf_free(phba, &nvmebuf->dbuf); + lpfc_in_buf_free(phba, &nvmebuf->dbuf); return; } ctxp->phba = phba; @@ -1814,8 +1813,7 @@ lpfc_nvmet_unsol_ls_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, ctxp->oxid, rc); /* We assume a rcv'ed cmd ALWAYs fits into 1 buffer */ - if (nvmebuf) - lpfc_in_buf_free(phba, &nvmebuf->dbuf); + lpfc_in_buf_free(phba, &nvmebuf->dbuf); atomic_inc(&tgtp->xmt_ls_abort); lpfc_nvmet_unsol_ls_issue_abort(phba, ctxp, sid, oxid);