From patchwork Fri Aug 8 15:34:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 4697061 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 9F84AC0338 for ; Fri, 8 Aug 2014 15:34:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAF1F20179 for ; Fri, 8 Aug 2014 15:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D80420158 for ; Fri, 8 Aug 2014 15:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756969AbaHHPeV (ORCPT ); Fri, 8 Aug 2014 11:34:21 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:37772 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756936AbaHHPeT (ORCPT ); Fri, 8 Aug 2014 11:34:19 -0400 Received: from ayla.of.borg ([84.193.84.167]) by albert.telenet-ops.be with bizsmtp id cFa71o00j3cczKo06Fa8iQ; Fri, 08 Aug 2014 17:34:18 +0200 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1XFmBD-00071V-3p; Fri, 08 Aug 2014 17:34:07 +0200 From: Geert Uytterhoeven To: Thomas Petazzoni , Jason Cooper , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr() Date: Fri, 8 Aug 2014 17:34:05 +0200 Message-Id: <1407512045-26969-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 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;