[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200116172403.18149-63-sashal@kernel.org>
Date: Thu, 16 Jan 2020 12:19:52 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Mattias Jacobsson <2pi@....nu>, Darren Hart <dvhart@...radead.org>,
Sasha Levin <sashal@...nel.org>,
platform-driver-x86@...r.kernel.org
Subject: [PATCH AUTOSEL 4.14 120/371] platform/x86: wmi: fix potential null pointer dereference
From: Mattias Jacobsson <2pi@....nu>
[ Upstream commit c355ec651a8941864549f2586f969d0eb7bf499a ]
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@....nu>
Signed-off-by: Darren Hart (VMware) <dvhart@...radead.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
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 7f8fa42a1084..a56e997816b2 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -748,6 +748,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
Powered by blists - more mailing lists