Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbcLDFiL (ORCPT ); Sun, 4 Dec 2016 00:38:11 -0500 Received: from m50-132.163.com ([123.125.50.132]:36784 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbcLDFiK (ORCPT ); Sun, 4 Dec 2016 00:38:10 -0500 From: Pan Bian To: Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] scsi: 3w-sas: set errno on failures Date: Sun, 4 Dec 2016 13:36:26 +0800 Message-Id: <1480829786-4725-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowAAH1Oxaq0NYiHmrIQ--.9673S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZFWfuF18CF18GF4fur1rZwb_yoW8XF1xpF 97Wa4Yk3y29ry8Gw4UGa13AFn09ayjq3yrWrWDtw1akasayryqqF1xWFy7tFy8ArWvkFW3 ta1qgryUWa17Jr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bTApnUUUUU= X-Originating-IP: [114.243.30.33] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/1tbiSBw291XlhBaXlgAAs2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1468 Lines: 44 From: Pan Bian On some error paths (e.g. pci_iomap() returns a NULL pointer), the value of return variable retval is 0. 0 means no error. This patch fixes the bug, set retval with negative errno on error paths. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189001 Signed-off-by: Pan Bian --- drivers/scsi/3w-sas.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index f837485..65b42b4 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1600,6 +1600,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) if (twl_initialize_device_extension(tw_dev)) { TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension"); + retval = -ENODEV; goto out_free_device_extension; } @@ -1614,6 +1615,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) tw_dev->base_addr = pci_iomap(pdev, 1, 0); if (!tw_dev->base_addr) { TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap"); + retval = -ENOMEM; goto out_release_mem_region; } @@ -1623,6 +1625,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) /* Initialize the card */ if (twl_reset_sequence(tw_dev, 0)) { TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe"); + retval = -ENODEV; goto out_iounmap; } -- 1.9.1