Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp828655imm; Fri, 27 Jul 2018 06:54:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc1EE75wJqOLb2K0m3LGWqyU2mH8pBFtJcBRQqgT1bpPuY8W7tvh1j1v/KTcsN3F94/yN/N X-Received: by 2002:a63:1b17:: with SMTP id b23-v6mr6272906pgb.275.1532699676750; Fri, 27 Jul 2018 06:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532699676; cv=none; d=google.com; s=arc-20160816; b=jEubjeBY/SBcxqjwYnZpqruV3ZA4//9KCPGptRCZzi7Y/fB3u04e1Vn1RDHiL255DC oB3lJ4o7U3rzv3690PY3oH8RmfhlBJUZNHuLe6e2WD8VmDsFfW8uYfGamfvpDl2IRs2B icKVBXtvf0MWLPI9U9xI3rsjRhzCMd0Zzg14gLAWscEMsuBSQu/TCdzZFtQ8JIvW7Jtu ZfmF6EGFUKo2JFNfudcDEYdSvkdGhIUsKoiC3hjT9ia1NlX+JAibXgLg1sE76zD8HGTm Xr+TUIaJqZKj62pVPKAEOTp7Z5bT/1HjDjR7vFFFjHNhsUYtliHVJ8b4TeItXRiIcFU+ TfeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ySC7HZ++Iw8XjM/HwA8WiEW14iECQRjHY8wOJzvRETo=; b=b/o6LgE0E0lJ5cKH1Y3se0AB69OqZMtCbAsEKY4znVQ5z3SjME41IlWhVyYexVxyZs vcdmbAlSOJYRIYpAxlyQUa09SavmKcVxDXRFDEZuwMvRUF3wa/5H0e9TypRtk5H3Ij1i fGGUeLYKBzdnd/d7hs6WJ+j9E0+txdY9BHTt+mAuIMIG4VRH20oiqK1qICTP4rcQvpB7 dmag1I1OjUh2VGkzCp3BmjkDOgDAxR/8TBxyM5+ymKEnnedudslXgAcCn7DxE2lKtfgL TTWcgJaNHHAozP+xo9ICCsFUV1tF5yWqlLQ2sJFoLuIOShchvwR+ZiyLXgVt9hJz16IH uZzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c32-v6si3756409pgc.129.2018.07.27.06.54.22; Fri, 27 Jul 2018 06:54:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388464AbeG0POP (ORCPT + 99 others); Fri, 27 Jul 2018 11:14:15 -0400 Received: from bran.ispras.ru ([83.149.199.196]:12443 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730088AbeG0POP (ORCPT ); Fri, 27 Jul 2018 11:14:15 -0400 Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id D58D9203C6; Fri, 27 Jul 2018 16:52:11 +0300 (MSK) From: Anton Vasilyev To: "James E.J. Bottomley" Cc: Anton Vasilyev , Adam Radford , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] scsi: 3ware: fix return 0 on the error path of probe Date: Fri, 27 Jul 2018 16:51:57 +0300 Message-Id: <20180727135157.13051-1-vasilyev@ispras.ru> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tw_probe() returns 0 in case of fail of tw_initialize_device_extension(), pci_resource_start() or tw_reset_sequence() and releases resources. twl_probe() returns 0 in case of fail of twl_initialize_device_extension(), pci_iomap() and twl_reset_sequence(). twa_probe() returns 0 in case of fail of tw_initialize_device_extension(), ioremap() and twa_reset_sequence(). The patch adds retval initialization for these cases. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- drivers/scsi/3w-9xxx.c | 6 +++++- drivers/scsi/3w-sas.c | 3 +++ drivers/scsi/3w-xxxx.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 99ba4a770406..27521fc3ef5a 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -2038,6 +2038,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) if (twa_initialize_device_extension(tw_dev)) { TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension"); + retval = -ENOMEM; goto out_free_device_extension; } @@ -2060,6 +2061,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) tw_dev->base_addr = ioremap(mem_addr, mem_len); if (!tw_dev->base_addr) { TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); + retval = -ENOMEM; goto out_release_mem_region; } @@ -2067,8 +2069,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) TW_DISABLE_INTERRUPTS(tw_dev); /* Initialize the card */ - if (twa_reset_sequence(tw_dev, 0)) + if (twa_reset_sequence(tw_dev, 0)) { + retval = -ENOMEM; goto out_iounmap; + } /* Set host specific parameters */ if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) || diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index cf9f2a09b47d..40c1e6e64f58 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1594,6 +1594,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 = -ENOMEM; goto out_free_device_extension; } @@ -1608,6 +1609,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; } @@ -1617,6 +1619,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 = -ENOMEM; goto out_iounmap; } diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index f6179e3d6953..961ea6f7def8 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -2280,6 +2280,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) if (tw_initialize_device_extension(tw_dev)) { printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension."); + retval = -ENOMEM; goto out_free_device_extension; } @@ -2294,6 +2295,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) tw_dev->base_addr = pci_resource_start(pdev, 0); if (!tw_dev->base_addr) { printk(KERN_WARNING "3w-xxxx: Failed to get io address."); + retval = -ENOMEM; goto out_release_mem_region; } -- 2.18.0