mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: "Mingyou Chen" <qby140326@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] platform/x86: bitland-mifs-wmi: Fix NULL pointer dereference during suspend/resume
Date: Mon, 22 Jun 2026 23:22:59 +0200	[thread overview]
Message-ID: <db81ecfc-9c7b-408c-9f65-6f1f77bf5eef@gmx.de> (raw)
In-Reply-To: <20260620081805.63773-1-qby140326@gmail.com>

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

  reply	other threads:[~2026-06-22 21:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20  8:18 Mingyou Chen
2026-06-22 21:22 ` Armin Wolf [this message]
2026-07-01 11:54 ` Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db81ecfc-9c7b-408c-9f65-6f1f77bf5eef@gmx.de \
    --to=w_armin@gmx.de \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=qby140326@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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