From: Fengguang Wu <fengguang.wu@intel.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiri Slaby <jslaby@suse.cz>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
jirislaby@gmail.com, Feng Tang <feng.tang@intel.com>
Subject: Re: [PATCH 1/1] PCI: fix on-stack pci_device_id's
Date: Tue, 11 Sep 2012 06:55:04 +0800 [thread overview]
Message-ID: <20120910225504.GA18038@localhost> (raw)
In-Reply-To: <CAErSpo4+zvG-MmQ2V2QNKjx=mX+nLpqZNj5niJkG4f22XqYZNg@mail.gmail.com>
On Mon, Sep 10, 2012 at 02:44:32PM -0600, Bjorn Helgaas wrote:
> On Mon, Sep 10, 2012 at 1:36 PM, Jiri Slaby <jslaby@suse.cz> wrote:
> > 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.
>
> Nice! I fixed this already by adding a memset(), but I like your way
> better. I knew we could initialize members of a structure on the
> stack, but I didn't know C guaranteed that uninitialized members would
> be implicitly initialized also. But apparently it does:
>
> http://stackoverflow.com/questions/10828294/c-and-c-partial-initialization-of-automatic-structure
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
For the record, I proposed the same initializer-style fix in the very
beginning that you didn't realize its beauty until now ;-)
Thanks,
Fengguang
next prev parent reply other threads:[~2012-09-10 22:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 19:36 [PATCH 1/1] PCI: fix on-stack pci_device_id's Jiri Slaby
2012-09-10 20:44 ` Bjorn Helgaas
2012-09-10 22:55 ` Fengguang Wu [this message]
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=20120910225504.GA18038@localhost \
--to=fengguang.wu@intel.com \
--cc=bhelgaas@google.com \
--cc=feng.tang@intel.com \
--cc=jirislaby@gmail.com \
--cc=jslaby@suse.cz \
--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