linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	jirislaby@gmail.com, Feng Tang <feng.tang@intel.com>,
	Fengguang Wu <fengguang.wu@intel.com>
Subject: [PATCH 1/1] PCI: fix on-stack pci_device_id's
Date: Mon, 10 Sep 2012 21:36:41 +0200	[thread overview]
Message-ID: <1347305801-7712-1-git-send-email-jslaby@suse.cz> (raw)

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 <jslaby@suse.cz>
Cc: Feng Tang <feng.tang@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
---
 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);
 }
-- 
1.7.11.5



             reply	other threads:[~2012-09-10 19:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 19:36 Jiri Slaby [this message]
2012-09-10 20:44 ` [PATCH 1/1] PCI: fix on-stack pci_device_id's Bjorn Helgaas
2012-09-10 22:55   ` Fengguang Wu
2012-09-11  0:02     ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347305801-7712-1-git-send-email-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=bhelgaas@google.com \
    --cc=feng.tang@intel.com \
    --cc=fengguang.wu@intel.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).