From patchwork Mon Apr 10 17:46:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9673889 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B64C360381 for ; Mon, 10 Apr 2017 17:47:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EDB427D4D for ; Mon, 10 Apr 2017 17:47:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 932C027FA8; Mon, 10 Apr 2017 17:47:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C8B27F7F for ; Mon, 10 Apr 2017 17:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbdDJRrX (ORCPT ); Mon, 10 Apr 2017 13:47:23 -0400 Received: from mail1.bemta12.messagelabs.com ([216.82.251.8]:44533 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbdDJRrV (ORCPT ); Mon, 10 Apr 2017 13:47:21 -0400 Received: from [216.82.249.212] by server-8.bemta-12.messagelabs.com id 52/E3-02036-215CBE85; Mon, 10 Apr 2017 17:46:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEIsWRWlGSWpSXmKPExsVy+LrFKl2ho68 jDPqu81j8nXSM3WLH0s1MFq/OrGWzuLxrDpvF2XnH2SwOLG1nsXjz+wW7xcEPT1gtWp7OYLT4 v+UzmwOXR//sKWwea+atYfT4/WsSo0f/us+sHptWdbJ5fN4kF8AWxZqZl5RfkcCacWfydvaC+ ewVP5adY2tgnMDWxcjFISSwjFGiYeda9i5GTg4RAV+JM392s4AkmAWuM0lcvLiZGSTBJmAicf P+ORYQW1jAQuLgmRVsIDavgLPEma9HgeIcHCwCqhKbnqqDhEUFEiQu/pnCClEiKHFy5hOwVmY BfYmmrXOYIWx5ie1vIWwhAW2J9xsXg9VLCChITJ3cyjyBkXcWkvZZSNpnIWlfwMi8ilG9OLWo LLVI10gvqSgzPaMkNzEzR9fQ0EgvN7W4ODE9NScxqVgvOT93EyMwvBmAYAdj2xznQ4ySHExKo rwBM19HCPEl5adUZiQWZ8QXleakFh9ilOHgUJLglToClBMsSk1PrUjLzAFGGkxagoNHSYS37D BQmre4IDG3ODMdInWKUZdjzr2v75mEWPLy81KlxHl3gxQJgBRllObBjYBF/SVGWSlhXkago4R 4ClKLcjNLUOVfMYpzMCoJ8/KBXMKTmVcCt+kV0BFMQEec2fUS5IiSRISUVAOj15+Ec4IrV965 yCr5XHwCY2WW83HWyR4eM8/M2+C+7dhs6bAUk953Nju4lSIKFTKmy2/l+Vh6Tc7ksL38nmD7d 2vL7tdHbN2t38ITXGE840uSOtsqDXPt7zuSP3MtPqQ3K5ft1t67t1MFjp/ofnhgmZDJ1uOff+ zyXOWyo6Rc+Nll56xNFouylFiKMxINtZiLihMB/Vnu9vUCAAA= X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-14.tower-219.messagelabs.com!1491846416!148342316!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30205 invoked from network); 10 Apr 2017 17:46:58 -0000 Received: from 195-215-56-170-static.dk.customer.tdc.net (HELO CPH-EX1.SDESIGNS.COM) (195.215.56.170) by server-14.tower-219.messagelabs.com with AES128-SHA encrypted SMTP; 10 Apr 2017 17:46:58 -0000 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 10 Apr 2017 19:46:55 +0200 To: Bjorn Helgaas , linux-pci CC: Robin Murphy , Lorenzo Pieralisi , Liviu Dudau , David Laight , Arnd Bergmann , Thibaud Cornic , Mason , Yinghai Lu , LKML From: Marc Gonzalez Subject: [PATCH] PCI: Improve __pci_read_base robustness Message-ID: <1c0ad12a-9bfc-2a76-ee76-6ab403f912d3@sigmadesigns.com> Date: Mon, 10 Apr 2017 19:46:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0 SeaMonkey/2.48 MIME-Version: 1.0 X-Originating-IP: [172.27.0.114] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Local variables 'l' and 'sz' are uninitialized. Normally, they would be initialized by pci_read_config_dword() but when an error occurs, some drivers immediately return an error code, which leaves the argument uninitialized. Provide a safe initial value to make the code more robust. Signed-off-by: Marc Gonzalez --- drivers/pci/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index d266d800f246..6fb929bd7040 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -175,7 +175,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar) int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, struct resource *res, unsigned int pos) { - u32 l, sz, mask; + u32 l = 0, sz = 0, mask; u64 l64, sz64, mask64; u16 orig_cmd; struct pci_bus_region region, inverted_region;