From patchwork Sat Apr 16 20:32:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102504 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp571372qge; Sat, 16 Apr 2016 13:33:23 -0700 (PDT) X-Received: by 10.98.20.6 with SMTP id 6mr9648744pfu.166.1460838803154; Sat, 16 Apr 2016 13:33:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb5si5540698pab.125.2016.04.16.13.33.22; Sat, 16 Apr 2016 13:33:23 -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 S1752085AbcDPUdV (ORCPT + 29 others); Sat, 16 Apr 2016 16:33:21 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:65295 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbcDPUdT (ORCPT ); Sat, 16 Apr 2016 16:33:19 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPA (Nemesis) id 0LhXRh-1bVFLy2DEf-00mqai; Sat, 16 Apr 2016 22:32:55 +0200 From: Arnd Bergmann To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Christoph Hellwig , Arnd Bergmann , James Bottomley , Ondrej Zary , Hannes Reinecke , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] aha1542: probe correct address for isapnp Date: Sat, 16 Apr 2016 22:32:41 +0200 Message-Id: <1460838770-1250252-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:XEu4hOmtRVednieYvDt5ZjaI1XM38m84qu+RAocIkbR77XiGQMM +/oTEewjOn4/mdlA2AiUBDA1FruM6C4nuoOaO+FGPCbIOsPXsfJzI4bwBmOMdjc/3oqrQmi B62m2vFM+AsMH5rUtMO66fHg/wXQWCPB7B1WZyT8QM6eywDcmb2kJk2EOxFTin3JWN7QC77 eF2+kNTKHr/lt/5zxXzkQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:IA3iGY66l1A=:mb4MdbRELVc9P7h96ikAF8 K3UKzxkb/6UkbK8sOrW/bXLDo8y61XIex6pN3gmx6zRfFgCAq8vB0sGNpMCfIB4hn1uK0ytdu DWOOzyJ5RkD5MRGBAWanskTVhCocRIEECm8woemaM8vfERaPz8r7jXVu2U6RE9/Yd24b7+eKN tACysVKW1mXFJgr9gPiQ69vrImahg8bvrPlbfm7xW3MkQcSajeNAOa8SS21LvoGkXPriKLza2 wK7Q/Q51g3WJHr8/L+oLJhduomsdPvawqX/sm0+X28OUvB7Z8sPMXzh4VOsOlHzKq6Tylykcy JDCf+GuSm9JB27QbpqawA6rCmvKcXqzNN0VfPHvhYHFPWvaQ3wNOQOo3qTTyRpiDvDPY33lGM NvuBHPb1zqnlxXr8cSFid2mek2MH6ZXHMCGIlYayaZdVv6CeXoAgIoWz0ufqR8F11/5Fjl1Fz 9pcg2m0cU2AIsxT0PtEywhqTNMZaaNcipJl5A42PUgj6rhiAN+jUUmL35Ql+QrxSIVHssuJBi lQosyf4ir0DcUKqBC5BDsencwDJfwAV2kUloQeE+jDNi9w2xoTr8HybUJ54t+uDiicLE0tx71 2T4wjcWC9tqkUWg8ItOB0jofrIGkRR1bDbjdtEA4+WVNls7N2BRNGuWefhYBg/GjnHttSXQcF xLySPXMjo6Q6w+mhO+6Kcv1iF5fZfNV7EOk4XRSRtEgeQxL303emIvjuxUE8xuAocvRs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warns about an out of bounds access after a recent cleanup: drivers/scsi/aha1542.c: In function 'aha1542_pnp_probe': drivers/scsi/aha1542.c:703:27: error: array subscript is above array bounds [-Werror=array-bounds] unsigned int base_io = io[indx]; ~~^~~~~~ drivers/scsi/aha1542.c:728:2: error: array subscript is above array bounds [-Werror=array-bounds] aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]); Indeed the aha1542_pnp_probe() function that was added cannot possibly have worked, as it first tries to find an available index to use for the probed device, but then passes one after the last index to the aha1542_hw_init() function. This is an attempt to rework the probe function into what it should have been. It is however not tested any more than the original patch other than making sure we get no warnings. Signed-off-by: Arnd Bergmann Fixes: 643a7c43f11e ("aha1542: Stop using scsi_module.c") --- drivers/scsi/aha1542.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) -- 2.7.0 diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 7db448ec8beb..132c311ef605 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -996,25 +996,31 @@ static int aha1542_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *i { int indx; struct Scsi_Host *sh; + int ret; - for (indx = 0; indx < ARRAY_SIZE(io); indx++) { - if (io[indx]) - continue; + for (indx = 0; indx < ARRAY_SIZE(io); indx++) + if (!io[indx]) + break; - if (pnp_activate_dev(pdev) < 0) - continue; + if (indx == ARRAY_SIZE(io)) + return -ENXIO; - io[indx] = pnp_port_start(pdev, 0); + ret = pnp_activate_dev(pdev); + if (ret < 0) + return ret; - /* The card can be queried for its DMA, we have - the DMA set up that is enough */ + io[indx] = pnp_port_start(pdev, 0); - dev_info(&pdev->dev, "ISAPnP found an AHA1535 at I/O 0x%03X", io[indx]); - } + /* The card can be queried for its DMA, we have + the DMA set up that is enough */ + + dev_info(&pdev->dev, "ISAPnP found an AHA1535 at I/O 0x%03X", io[indx]); sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); - if (!sh) + if (!sh) { + pnp_disable_dev(pdev); return -ENODEV; + } pnp_set_drvdata(pdev, sh); return 0;