platform/x86: wmi: Fix driver->notify() vs ->probe() race
authorHans de Goede <hdegoede@redhat.com>
Sun, 28 Nov 2021 19:00:28 +0000 (20:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jul 2022 14:34:53 +0000 (16:34 +0200)
commit9846b9e4bba796564f90f7c4555f429a5395bee6
treed13e6e9e28e04863fa97294d4dde72d48ceff318
parent4b53562319894fad2b13883562af316c6efaa48a
platform/x86: wmi: Fix driver->notify() vs ->probe() race

[ Upstream commit 9918878676a5f9e99b98679f04b9e6c0f5426b0a ]

The driver core sets struct device->driver before calling out
to the bus' probe() method, this leaves a window where an ACPI
notify may happen on the WMI object before the driver's
probe() method has completed running, causing e.g. the
driver's notify() callback to get called with drvdata
not yet being set leading to a NULL pointer deref.

At a check for this to the WMI core, ensuring that the notify()
callback is not called before the driver is ready.

Fixes: 1686f5444546 ("platform/x86: wmi: Incorporate acpi_install_notify_handler")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-2-hdegoede@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/wmi.c