* [PATCH v2] platform/x86: wmi: fix potential null pointer dereference
@ 2019-01-30 15:14 Mattias Jacobsson
2019-01-30 15:43 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Mattias Jacobsson @ 2019-01-30 15:14 UTC (permalink / raw)
To: dvhart, andy; +Cc: 2pi, platform-driver-x86, linux-kernel
In the function wmi_dev_match() the variable id is dereferenced without
first performing a NULL check. The variable can for example be NULL if
a WMI driver is registered without specifying the id_table field in
struct wmi_driver.
Add a NULL check and return that the driver can't handle the device if
the variable is NULL.
Fixes: 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver")
Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
---
drivers/platform/x86/wmi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index bea35be68706..b0f3d8ecd898 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -768,6 +768,9 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)
struct wmi_block *wblock = dev_to_wblock(dev);
const struct wmi_device_id *id = wmi_driver->id_table;
+ if (id == NULL)
+ return 0;
+
while (id->guid_string) {
uuid_le driver_guid;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] platform/x86: wmi: fix potential null pointer dereference
2019-01-30 15:14 [PATCH v2] platform/x86: wmi: fix potential null pointer dereference Mattias Jacobsson
@ 2019-01-30 15:43 ` Andy Shevchenko
2019-02-21 1:29 ` Darren Hart
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2019-01-30 15:43 UTC (permalink / raw)
To: Mattias Jacobsson
Cc: Darren Hart, Andy Shevchenko, Platform Driver,
Linux Kernel Mailing List
On Wed, Jan 30, 2019 at 5:15 PM Mattias Jacobsson <2pi@mok.nu> wrote:
>
> In the function wmi_dev_match() the variable id is dereferenced without
> first performing a NULL check. The variable can for example be NULL if
> a WMI driver is registered without specifying the id_table field in
> struct wmi_driver.
>
> Add a NULL check and return that the driver can't handle the device if
> the variable is NULL.
>
Good for me, thanks!
> Fixes: 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver")
> Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
> ---
> drivers/platform/x86/wmi.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index bea35be68706..b0f3d8ecd898 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -768,6 +768,9 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)
> struct wmi_block *wblock = dev_to_wblock(dev);
> const struct wmi_device_id *id = wmi_driver->id_table;
>
> + if (id == NULL)
> + return 0;
> +
> while (id->guid_string) {
> uuid_le driver_guid;
>
> --
> 2.20.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] platform/x86: wmi: fix potential null pointer dereference
2019-01-30 15:43 ` Andy Shevchenko
@ 2019-02-21 1:29 ` Darren Hart
0 siblings, 0 replies; 3+ messages in thread
From: Darren Hart @ 2019-02-21 1:29 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Mattias Jacobsson, Andy Shevchenko, Platform Driver,
Linux Kernel Mailing List
On Wed, Jan 30, 2019 at 05:43:34PM +0200, Andy Shevchenko wrote:
> On Wed, Jan 30, 2019 at 5:15 PM Mattias Jacobsson <2pi@mok.nu> wrote:
> >
> > In the function wmi_dev_match() the variable id is dereferenced without
> > first performing a NULL check. The variable can for example be NULL if
> > a WMI driver is registered without specifying the id_table field in
> > struct wmi_driver.
> >
> > Add a NULL check and return that the driver can't handle the device if
> > the variable is NULL.
> >
>
> Good for me, thanks!
Queued for testing, thanks Mattias.
--
Darren Hart
VMware Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-21 1:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-30 15:14 [PATCH v2] platform/x86: wmi: fix potential null pointer dereference Mattias Jacobsson
2019-01-30 15:43 ` Andy Shevchenko
2019-02-21 1:29 ` Darren Hart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox