[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171020145731.GF8965@kroah.com>
Date: Fri, 20 Oct 2017 16:57:31 +0200
From: Greg KH <greg@...ah.com>
To: Mario.Limonciello@...l.com
Cc: dvhart@...radead.org, andy.shevchenko@...il.com,
linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
luto@...nel.org, quasisec@...gle.com, pali.rohar@...il.com,
rjw@...ysocki.net, mjg59@...gle.com, hch@....de,
gnomes@...rguk.ukuu.org.uk
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface
for drivers
On Fri, Oct 20, 2017 at 01:54:36PM +0000, Mario.Limonciello@...l.com wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:greg@...ah.com]
> > Sent: Friday, October 20, 2017 8:22 AM
> > To: Limonciello, Mario <Mario_Limonciello@...l.com>
> > Cc: dvhart@...radead.org; Andy Shevchenko <andy.shevchenko@...il.com>;
> > LKML <linux-kernel@...r.kernel.org>; platform-driver-x86@...r.kernel.org; Andy
> > Lutomirski <luto@...nel.org>; quasisec@...gle.com; pali.rohar@...il.com;
> > rjw@...ysocki.net; mjg59@...gle.com; hch@....de; Alan Cox
> > <gnomes@...rguk.ukuu.org.uk>
> > Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for
> > drivers
> >
> > On Thu, Oct 19, 2017 at 12:50:16PM -0500, Mario Limonciello wrote:
> > > + wblock = container_of(wdev, struct wmi_block, dev);
> > > + if (!wblock)
> > > + return -ENODEV;
> >
> > How can container_of() ever return NULL? If so, you have a very odd
> > memory layout...
> >
>
> I'm assuming this is from set_required_buffer_size right?
>
> The symbol is exported out for other drivers to use. It's possible for another
> driver to allocate a wmi_device structure that's not part of a wblock.
Fine, but your test does not do anything at all.
> > > + list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
> > > + wdriver = container_of(wblock->dev.dev.driver,
> > > + struct wmi_driver, driver);
> > > + if (!wdriver)
> > > + continue;
> >
> > Same here. And other places in this file.
> >
>
> This one it's possible that a driver isn't bound to a device, and when
> that happens wdriver is NULL.
Again, that's not what you are testing at all.
container_of() is just pointer math. If you pass in NULL, you will get
a non-NULL value (incremented or decremented). If you pass in a very
tiny number, you might get NULL, but that's still really wrong.
In other words, these tests will _NEVER_ fail. Go ahead, try it :)
thanks,
greg k-h
Powered by blists - more mailing lists