From patchwork Mon Sep 10 19:36:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 1433451 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8A7DDDFFCF for ; Mon, 10 Sep 2012 19:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184Ab2IJToR (ORCPT ); Mon, 10 Sep 2012 15:44:17 -0400 Received: from mail.pripojeni.net ([178.22.112.14]:50901 "EHLO smtp.pripojeni.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932183Ab2IJToO (ORCPT ); Mon, 10 Sep 2012 15:44:14 -0400 X-Greylist: delayed 448 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Sep 2012 15:44:13 EDT Received: from localhost.localdomain ([178.22.113.142]) by smtp.pripojeni.net (Kerio Connect 7.2.2); Mon, 10 Sep 2012 21:36:41 +0200 From: Jiri Slaby To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, jirislaby@gmail.com, Feng Tang , Fengguang Wu Subject: [PATCH 1/1] PCI: fix on-stack pci_device_id's Date: Mon, 10 Sep 2012 21:36:41 +0200 Message-Id: <1347305801-7712-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 1.7.11.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Commit "PCI: Use pci_device_id on stack for pci_get_subsys/class() to avoid kmalloc" changed heap allocations to on-stack variables, but it did not add initialization of other than set members. This causes random failures during bootup wherever pci device is needed to be found. Hence the boot just hangs or panics. This patches fixes it by setting the content of pci_device_id directly in the initializer. Signed-off-by: Jiri Slaby Cc: Feng Tang Cc: Bjorn Helgaas Cc: Fengguang Wu Signed-off-by: Fengguang Wu --- drivers/pci/search.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 00d486a..bf969ba 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -243,12 +243,12 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) { - struct pci_device_id id; - - id.vendor = vendor; - id.device = device; - id.subvendor = ss_vendor; - id.subdevice = ss_device; + struct pci_device_id id = { + .vendor = vendor, + .device = device, + .subvendor = ss_vendor, + .subdevice = ss_device, + }; return pci_get_dev_by_id(&id, from); } @@ -289,11 +289,14 @@ pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from) */ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) { - struct pci_device_id id; - - id.vendor = id.device = id.subvendor = id.subdevice = PCI_ANY_ID; - id.class_mask = PCI_ANY_ID; - id.class = class; + struct pci_device_id id = { + .vendor = PCI_ANY_ID, + .device = PCI_ANY_ID, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .class_mask = PCI_ANY_ID, + .class = class, + }; return pci_get_dev_by_id(&id, from); }