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: 4853811 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 F32E3C0338 for ; Fri, 5 Sep 2014 17:41:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27E3620225 for ; Fri, 5 Sep 2014 17:41:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 441372021A for ; Fri, 5 Sep 2014 17:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750863AbaIERl1 (ORCPT ); Fri, 5 Sep 2014 13:41:27 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:63434 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbaIERl0 (ORCPT ); Fri, 5 Sep 2014 13:41:26 -0400 Received: by mail-pa0-f49.google.com with SMTP id kq14so22562164pab.36 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=M9GM4LZJz3ZRQK/pXLJiDacfc7mHVfwCwa/gmewGpAgQ+IRHLC3OUQGTdwuMjQ87/x NzXLT4zKhBlHcMFQgpFa28jofcfkRtLlQPBS/Bp8ew3jPi13wnpWIahGSzvogFiKJP5x uTwqVSvIx/WRDKhvlBANbgwRkSQg74p+8UssQ2I88+N8mqesJZvLJkmrjT6jzu5bLfTF 3C6TDa6HuTdJc+rCjWjIekJZtCOUbyh2Qc3uYggqz335tS6uQ3zk2yy8X7g42snxHcii gCXx3h25+TSQeSSsZckZUSbP9wumGCTkY2Nzua2yjitHf28wkI8sA3n8bM+COugtxt1m ovhQ== X-Gm-Message-State: ALoCoQk8pL//0yTwrCpLErU4IN4v5IgPYMHuvTjbKSWyUf2pSERt5OSqylL7uu8we/uPA0MlFLW4 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 Cc: Thomas Petazzoni , Jason Cooper , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, 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+ --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;