From patchwork Tue Oct 24 02:29:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10023429 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 4223D601E8 for ; Tue, 24 Oct 2017 02:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C9A528957 for ; Tue, 24 Oct 2017 02:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 218CE2895A; Tue, 24 Oct 2017 02:30:36 +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=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 342BA28958 for ; Tue, 24 Oct 2017 02:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbdJXCaN (ORCPT ); Mon, 23 Oct 2017 22:30:13 -0400 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:54658 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751277AbdJXCaM (ORCPT ); Mon, 23 Oct 2017 22:30:12 -0400 Received: from localhost.localdomain ([86.196.182.67]) by mwinf5d70 with ME id REW81w0071TfVo603EW85G; Tue, 24 Oct 2017 04:30:09 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 24 Oct 2017 04:30:09 +0200 X-ME-IP: 86.196.182.67 From: Christophe JAILLET To: aacraid@microsemi.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH V2] scsi: aacraid: Fix some error code Date: Tue, 24 Oct 2017 04:29:46 +0200 Message-Id: <20171024022946.30223-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 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 If 'scsi_host_alloc', 'kzalloc' or '(*aac_drivers[index].init)' fail, the function will return 0, because 'error' is known to be 0 at this point. Return -ENOMEM in the 2 first cases and -ENODEV in the third one. This patch also removes a useless 'error = -ENODEV'. Signed-off-by: Christophe JAILLET --- V2: rebase against latest -next (20171019) --- drivers/scsi/aacraid/linit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index c9252b138c1f..7e7d9bfd2b9e 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1628,7 +1628,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) error = pci_enable_device(pdev); if (error) goto out; - error = -ENODEV; if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) { error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); @@ -1660,6 +1659,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev)); + error = -ENOMEM; if (!shost) goto out_disable_pdev; @@ -1681,6 +1681,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) INIT_LIST_HEAD(&aac->entry); aac->fibs = kzalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL); + error = -ENOMEM; if (!aac->fibs) goto out_free_host; spin_lock_init(&aac->fib_lock); @@ -1690,6 +1691,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) * Map in the registers from the adapter. */ aac->base_size = AAC_MIN_FOOTPRINT_SIZE; + error = -ENODEV; if ((*aac_drivers[index].init)(aac)) goto out_unmap;