Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4273809imm; Mon, 30 Jul 2018 11:33:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdEcvnQ96jZJ/tsVbs+PPHpHjScixgP3tk4/3Evx5ALzJZyh80BFqvQK5Dw5keXb0yfg0re X-Received: by 2002:a63:ec14:: with SMTP id j20-v6mr17123392pgh.28.1532975594644; Mon, 30 Jul 2018 11:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532975594; cv=none; d=google.com; s=arc-20160816; b=GvulJYMHnA6T/J0G1VEO9kA8nctH59wrc9JFvM+SFKiXNwB/LI7EDkGIUkHxZPeWSO AZ339G9G+vEVsmeyH7ZKRJNGFJ88xdT3SLzAqMzvHZImO/4vDJBMd9SOxsBfiUsn/Nx1 dhVTp6UKR7dB5uHg5FrshAg8pCeuh6VJpmOC3hHZI/iRzXkTRbh93eNRHI52z17QsTyb wTx3DImDj+Euhp85v/AH74HFX9f7/PBgA+ZQWp69XUmbS8Fc6sDl0n9J9JClPVF5hA/Z mN0HKXBQtLsMiZM2xtO9w1Se0kPDFXj5Ixe8xYq7gN8qliOZwflEiqR7ktISQ4R4aNWo z6uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=tbtfMztZVlt2N/oAaJpIbXBN96tmLGvYElq2ozMYaIg=; b=FbQmyBOZj2z6/fFBEmoisoPjh0fwcWo1i/D4A8M8wbF5NmsUHLbfV0eN7GzD9cyWbD KFPzLkLfDdnl4FjNJ8so92QQj4HaltvtV9FA0ikD30qqOfXyR9J6CwSmHbIsAqdZ2RGR 6l5H0r1pos0vMFgWXhj7ksHDppS4fGHhPkDUFFcyDT5VxS+ZuTpg8LK53hW5bZ9xqy3b 1+3jAVycHAKJmgWRm+QmjwHI8scoaUSu3KyJgbHSsjvVhoWCHG9JB9GJVC+cJ2hfzv3X E4bqXnadd/lx3Lxs+m8FXrno3+uN6hSoxnv5YgUgRhQRbbYz4BYURuZpc2jrfU42tsGP rI/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="IjmR/vzZ"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4-v6si11946289pfc.328.2018.07.30.11.32.47; Mon, 30 Jul 2018 11:33:14 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="IjmR/vzZ"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730482AbeG3UHl (ORCPT + 99 others); Mon, 30 Jul 2018 16:07:41 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33281 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728965AbeG3UHk (ORCPT ); Mon, 30 Jul 2018 16:07:40 -0400 Received: by mail-oi0-f68.google.com with SMTP id l10-v6so23105219oii.0; Mon, 30 Jul 2018 11:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tbtfMztZVlt2N/oAaJpIbXBN96tmLGvYElq2ozMYaIg=; b=IjmR/vzZCi1yPNnO5OKlSn/OAo4+4gvGZdTQWe5+cZ6wv+H/h41S4QAYRPity/vRl3 3vQ7U3Sf55/CPqPrBP/xMi4iozliQC3KgcMQ+2jKx08mM/oRsTiA9D3e3Iq3zJeigZ/v VppqlhxV+iU8U2X91gPWvPVPvgglfRAb0K7wUznoY9sYq2KEgszFmCpVrpCHSS9aAdyz 9BV8tvPLuLuLnTnnPK2uW74KztAhe6w3IsbLV04g96jGFAcWTZgtDZkZt8katI2ouDal WSGWACq0pfVAU/ieIpQ90WqcRWcAPZ9Iuq/N/E5wHUGqFd0b+aSDPQA6S4v+oP+4y21j iWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tbtfMztZVlt2N/oAaJpIbXBN96tmLGvYElq2ozMYaIg=; b=fyGs7mz1prlyv9hO9uCXvX3N8mMTMgm7ZLSNmB+6Dr4AgCxYSKLm3+WvLLvnB07poQ QeWlg0nvP+QwdpSi4n2iIRikXD6g/Qu35YNaXNbegfmGD7HXmetoR+y4HD5teTv2U9ZS 0K4nVfoWgYHgtDaSh9LNP+sVzy8f+DdDkZAA8NcJacEB0zhGi//SEOvTzChI56iCZUqT HASEUGLE/5MCvkT5e6TlqC4WFXk4uVQuGCqkkb9xWimbRdym3j5GYQAK/omQMEXNG1Cn USLo07JgEOJFvmTv4gikEfrpWpUfrXgU9ylf3v4QYwPLOPk+uvPbjqhWPuJbSHcqca+n PnlA== X-Gm-Message-State: AOUpUlH6EV8t7Obmnu3v4ZBhB0HYjA0qDniYywaolksITbTGE1YSQmcm et1Y9HLr+PWXiALn4YnPIRAfqnvdIozJ/VYo6P4= X-Received: by 2002:aca:f383:: with SMTP id r125-v6mr18262591oih.6.1532975484581; Mon, 30 Jul 2018 11:31:24 -0700 (PDT) MIME-Version: 1.0 References: <20180727135157.13051-1-vasilyev@ispras.ru> In-Reply-To: From: adam radford Date: Mon, 30 Jul 2018 11:31:13 -0700 Message-ID: Subject: Re: [PATCH] scsi: 3ware: fix return 0 on the error path of probe To: anton.vasilyev.87@gmail.com Cc: vasilyev@ispras.ru, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi , linux-kernel , ldv-project@linuxtesting.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 28, 2018 at 8:18 AM Anton Vasilyev wrote: > > Adam, > > 3w-9xxx: twa_probe(): > > There is check of retval: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/scsi/3w-9xxx.c#n2010 > > retval without assignement is 0 on fail of twa_initialize_device_extensio= n(): > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/scsi/3w-9xxx.c#n2040 > > And this 0 is returned from probe on the error path. > > Same pattern is true for all other cases from patch. > > -Anton > > 27 =D0=B8=D1=8E=D0=BB. 2018 =D0=B3. 9:42 =D0=9F=D0=9F =D0=BF=D0=BE=D0=BB= =D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "adam radford" =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > > On Fri, Jul 27, 2018 at 6:52 AM Anton Vasilyev wrote= : > > > > 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_extensio= n(), > > 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 ini= tialize device extension"); > > + retval =3D -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 =3D ioremap(mem_addr, mem_len); > > if (!tw_dev->base_addr) { > > TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ior= emap"); > > + retval =3D -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 =3D -ENOMEM; > > goto out_iounmap; > > + } > > > > /* Set host specific parameters */ > > if ((pdev->device =3D=3D 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 ini= tialize device extension"); > > + retval =3D -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 =3D pci_iomap(pdev, 1, 0); > > if (!tw_dev->base_addr) { > > TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ior= emap"); > > + retval =3D -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 re= set failed during probe"); > > + retval =3D -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 s= truct pci_device_id *dev_id) > > > > if (tw_initialize_device_extension(tw_dev)) { > > printk(KERN_WARNING "3w-xxxx: Failed to initialize devi= ce extension."); > > + retval =3D -ENOMEM; > > goto out_free_device_extension; > > } > > > > @@ -2294,6 +2295,7 @@ static int tw_probe(struct pci_dev *pdev, const s= truct pci_device_id *dev_id) > > tw_dev->base_addr =3D pci_resource_start(pdev, 0); > > if (!tw_dev->base_addr) { > > printk(KERN_WARNING "3w-xxxx: Failed to get io address.= "); > > + retval =3D -ENOMEM; > > goto out_release_mem_region; > > } > > > > -- > > 2.18.0 > > > > Anton, > > 3w-9xxx: twa_probe() initializes retval at the top of the function: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/scsi/3w-9xxx.c#n2007 > > so does 3w-xxxx: tw_probe(): > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/scsi/3w-xxxx.c#n2253 > > so does 3w-sas: twl_probe(): > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/scsi/3w-sas.c#n1562 > > so I think your patch isn't needed... > > > -Adam > > > Acked-by: Adam Radford