* [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume
@ 2026-06-20 8:18 Mingyou Chen
2026-06-22 21:22 ` Armin Wolf
2026-07-01 11:54 ` Ilpo Järvinen
0 siblings, 2 replies; 3+ messages in thread
From: Mingyou Chen @ 2026-06-20 8:18 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen, platform-driver-x86, linux-kernel
Cc: Mingyou Chen
The driver registers two distinct WMI devices: a control device
(BITLAND_WMI_CONTROL) and an event device (BITLAND_WMI_EVENT). During
the probe phase, the event device handling path returns early before
initializing the platform profile device (data->pp_dev), leaving it
NULL.
However, the PM sleep operations are registered globally for the WMI
driver
and are triggered for both devices. When entering suspend, the event
device
invokes bitland_mifs_wmi_suspend(), which passes the uninitialized
data->pp_dev (NULL) into laptop_profile_get(). This leads to a NULL
pointer
dereference inside dev_get_drvdata(), causing a kernel Oops and halting
the
suspend sequence.
Fix this by adding a validity check for data->pp_dev in both the suspend
and resume callbacks, safely skipping profile operations for the event
device.
Signed-off-by: Mingyou Chen <qby140326@gmail.com>
---
drivers/platform/x86/bitland-mifs-wmi.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
index b0d06a80e89e..3a373184519d 100644
--- a/drivers/platform/x86/bitland-mifs-wmi.c
+++ b/drivers/platform/x86/bitland-mifs-wmi.c
@@ -300,6 +300,10 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
enum platform_profile_option profile;
int ret;
+ /* Skip event device */
+ if (!data->pp_dev)
+ return 0;
+
ret = laptop_profile_get(data->pp_dev, &profile);
if (ret == 0)
data->saved_profile = profile;
@@ -311,6 +315,10 @@ static int bitland_mifs_wmi_resume(struct device *dev)
{
struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
+ /* Skip event device */
+ if (!data->pp_dev)
+ return 0;
+
dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
return laptop_profile_set(dev, data->saved_profile);
}
base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume
2026-06-20 8:18 [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume Mingyou Chen
@ 2026-06-22 21:22 ` Armin Wolf
2026-07-01 11:54 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Armin Wolf @ 2026-06-22 21:22 UTC (permalink / raw)
To: Mingyou Chen, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel
Am 20.06.26 um 10:18 schrieb Mingyou Chen:
> The driver registers two distinct WMI devices: a control device
> (BITLAND_WMI_CONTROL) and an event device (BITLAND_WMI_EVENT). During
> the probe phase, the event device handling path returns early before
> initializing the platform profile device (data->pp_dev), leaving it
> NULL.
>
> However, the PM sleep operations are registered globally for the WMI
> driver
> and are triggered for both devices. When entering suspend, the event
> device
> invokes bitland_mifs_wmi_suspend(), which passes the uninitialized
> data->pp_dev (NULL) into laptop_profile_get(). This leads to a NULL
> pointer
> dereference inside dev_get_drvdata(), causing a kernel Oops and halting
> the
> suspend sequence.
>
> Fix this by adding a validity check for data->pp_dev in both the suspend
> and resume callbacks, safely skipping profile operations for the event
> device.
Hi,
very good catch, i totally missed this during the initial review xd.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>
> Signed-off-by: Mingyou Chen <qby140326@gmail.com>
> ---
> drivers/platform/x86/bitland-mifs-wmi.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
> index b0d06a80e89e..3a373184519d 100644
> --- a/drivers/platform/x86/bitland-mifs-wmi.c
> +++ b/drivers/platform/x86/bitland-mifs-wmi.c
> @@ -300,6 +300,10 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
> enum platform_profile_option profile;
> int ret;
>
> + /* Skip event device */
> + if (!data->pp_dev)
> + return 0;
> +
> ret = laptop_profile_get(data->pp_dev, &profile);
> if (ret == 0)
> data->saved_profile = profile;
> @@ -311,6 +315,10 @@ static int bitland_mifs_wmi_resume(struct device *dev)
> {
> struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
>
> + /* Skip event device */
> + if (!data->pp_dev)
> + return 0;
> +
> dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
> return laptop_profile_set(dev, data->saved_profile);
> }
>
> base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume
2026-06-20 8:18 [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume Mingyou Chen
2026-06-22 21:22 ` Armin Wolf
@ 2026-07-01 11:54 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2026-07-01 11:54 UTC (permalink / raw)
To: Mingyou Chen; +Cc: Hans de Goede, platform-driver-x86, LKML
On Sat, 20 Jun 2026, Mingyou Chen wrote:
> The driver registers two distinct WMI devices: a control device
> (BITLAND_WMI_CONTROL) and an event device (BITLAND_WMI_EVENT). During
> the probe phase, the event device handling path returns early before
> initializing the platform profile device (data->pp_dev), leaving it
> NULL.
>
> However, the PM sleep operations are registered globally for the WMI
> driver
> and are triggered for both devices. When entering suspend, the event
> device
> invokes bitland_mifs_wmi_suspend(), which passes the uninitialized
> data->pp_dev (NULL) into laptop_profile_get(). This leads to a NULL
> pointer
> dereference inside dev_get_drvdata(), causing a kernel Oops and halting
> the
> suspend sequence.
>
> Fix this by adding a validity check for data->pp_dev in both the suspend
> and resume callbacks, safely skipping profile operations for the event
> device.
>
> Signed-off-by: Mingyou Chen <qby140326@gmail.com>
This seems to be missing a Fixes tag?
> ---
> drivers/platform/x86/bitland-mifs-wmi.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
> index b0d06a80e89e..3a373184519d 100644
> --- a/drivers/platform/x86/bitland-mifs-wmi.c
> +++ b/drivers/platform/x86/bitland-mifs-wmi.c
> @@ -300,6 +300,10 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
> enum platform_profile_option profile;
> int ret;
>
> + /* Skip event device */
> + if (!data->pp_dev)
> + return 0;
> +
> ret = laptop_profile_get(data->pp_dev, &profile);
> if (ret == 0)
> data->saved_profile = profile;
> @@ -311,6 +315,10 @@ static int bitland_mifs_wmi_resume(struct device *dev)
> {
> struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
>
> + /* Skip event device */
> + if (!data->pp_dev)
> + return 0;
> +
> dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
> return laptop_profile_set(dev, data->saved_profile);
> }
>
> base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
>
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-01 11:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-20 8:18 [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume Mingyou Chen
2026-06-22 21:22 ` Armin Wolf
2026-07-01 11:54 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome