From patchwork Fri Sep 5 17:41:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4853831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 93330C0338 for ; Fri, 5 Sep 2014 17:43:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3BC52021A for ; Fri, 5 Sep 2014 17:43:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 827E02020E for ; Fri, 5 Sep 2014 17:43:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPxWB-0004Q5-ML; Fri, 05 Sep 2014 17:41:51 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPxW9-0004Dl-8n for linux-arm-kernel@lists.infradead.org; Fri, 05 Sep 2014 17:41:49 +0000 Received: by mail-pa0-f46.google.com with SMTP id eu11so22767715pac.33 for ; Fri, 05 Sep 2014 10:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=LmT515Z8uFd2ZdxtWmT2msagueVGtETFrlUkmmF84Tw=; b=enQLkW522O6YIIKd/phAXQ+H+YZwpP9AzcyjLqaKpMRXvR1fM89cgAcnydsn80foDQ 977p/W+m3Inr6me7W7OpOGmss7KcCznnuAp4O2d3k5BdqgS6Jv1fUO835OsAGXLdt03A OO11lmfmQXeW3QHrzPsYu9ksJgUiOQSNQJac4+6Wl8QOY7qOO68WlBAGhJaqrCuEfKyv Nz+Rg8h9ktXoK5TRvlIitd7AtZHynRY506GVDFRqlZm/JgQ9vQ4repwvtHsrNVbMGlM6 fcuRZEClIhwkgGo8pcTaESGJZ+a0Sjy7cyXQ3cG+KKkzuL11UOVFGpv/4CT6Pjb8G3hv 60Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=LmT515Z8uFd2ZdxtWmT2msagueVGtETFrlUkmmF84Tw=; b=C1vv+205E567XiT1U2k8WVz2UUC6UJuZdquddtgZgHZhMAAdrJEPnzBUawKMB4LpKR FrqQhBO97GRmKAyVEqPg3PPt7/x5Ltrhkdr8o9nQa9l5jC80/30YCSeJEE2uTDpB4q77 FpcdTIyfDf30qf1fReasdS24UOjReoJsbZBIZ4s6A+RcM4RUSwyh7beVjS3z7JWFFfZz Cxs+C7NSimI86ZYnL56ss8zGGgci/jPOnwjtUgoMWd+/BV1MQWgNEPhxtaTJbM+EVByD jx5NcpGgECuMxFCYrtfSeqULHAgV6dmra/c6wbbs8C+aSL5VKkeexXWVEOJInNiO+n6J rVNA== X-Gm-Message-State: ALoCoQlts+w7ZldtTDGbqhDBSmpS1HNuL8AjJ//OfdmsNBt2i1CoxRMdQZHy+bnQbCoNBehUV96T X-Received: by 10.66.182.10 with SMTP id ea10mr23080067pac.123.1409938886220; Fri, 05 Sep 2014 10:41:26 -0700 (PDT) Received: from google.com ([172.26.50.7]) by mx.google.com with ESMTPSA id dr5sm2263620pbb.24.2014.09.05.10.41.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 05 Sep 2014 10:41:25 -0700 (PDT) Date: Fri, 5 Sep 2014 11:41:22 -0600 From: Bjorn Helgaas To: Geert Uytterhoeven Subject: Re: [PATCH] PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr() Message-ID: <20140905174122.GD8080@google.com> References: <1407512045-26969-1-git-send-email-geert+renesas@glider.be> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1407512045-26969-1-git-send-email-geert+renesas@glider.be> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140905_104149_334104_E7F923E2 X-CRM114-Status: GOOD ( 19.56 ) X-Spam-Score: -2.5 (--) Cc: Thomas Petazzoni , linux-pci@vger.kernel.org, Jason Cooper , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Aug 08, 2014 at 05:34:05PM +0200, Geert Uytterhoeven wrote: > drivers/pci/host/pci-mvebu.c: In function 'mvebu_get_tgt_attr': > drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized] > if (slot == PCI_SLOT(devfn) && type == rtype) { > ^ > > If there's ever gonna be a configuration space or 64-bit memory space > entry in DT, rtype will be uninitialized, and the wrong entry may be > returned. > > Initialize rtype to 0 (which is an unused IORESOURCE_* type) to fix this. > > Introduced in commit 11be65472a427dcf7a11ab6e3e3628f1c6768b5b ("PCI: > mvebu: Adapt to the new device tree layout"). > > Signed-off-by: Geert Uytterhoeven > --- > Alternatively, should the "else if (DT_FLAGS_TO_TYPE(flags) == > DT_TYPE_MEM32)" just be changed to "else", assuming there can never be > other entries than for I/O or 32-bit memory space? > --- > drivers/pci/host/pci-mvebu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c > index ce23e0f076b6..9515f0d13fd4 100644 > --- a/drivers/pci/host/pci-mvebu.c > +++ b/drivers/pci/host/pci-mvebu.c > @@ -877,7 +877,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn, > u32 flags = of_read_number(range, 1); > u32 slot = of_read_number(range + 1, 1); > u64 cpuaddr = of_read_number(range + na, pna); > - unsigned long rtype; > + unsigned long rtype = 0; > > if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_IO) > rtype = IORESOURCE_IO; > -- > 1.9.1 > This fix looks right to me. I added a stable tag as follows. Thomas and/or Jason, and you ack this? commit f96f4040d0d01b6eeacda212cf7db105d06a55ba Author: Geert Uytterhoeven Date: Fri Aug 8 17:34:05 2014 +0200 PCI: mvebu: Fix uninitialized "rtype" in mvebu_get_tgt_attr() drivers/pci/host/pci-mvebu.c: In function 'mvebu_get_tgt_attr': drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized] if (slot == PCI_SLOT(devfn) && type == rtype) { ^ If there's ever a DT entry other than DT_TYPE_IO or DT_TYPE_MEM32, e.g., a configuration space or 64-bit memory space entry, rtype will be uninitialized, and the wrong entry may be returned. Initialize rtype to 0 (which is an unused IORESOURCE_* type) to fix this. Fixes: 11be65472a42 ("PCI: mvebu: Adapt to the new device tree layout") Signed-off-by: Geert Uytterhoeven Signed-off-by: Bjorn Helgaas CC: stable@vger.kernel.org # v3.12+ diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index a8c6f1a92e0f..081579c0971e 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -877,7 +877,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn, u32 flags = of_read_number(range, 1); u32 slot = of_read_number(range + 1, 1); u64 cpuaddr = of_read_number(range + na, pna); - unsigned long rtype; + unsigned long rtype = 0; if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_IO) rtype = IORESOURCE_IO;