X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Chenyuan Yang <chenyuan0y@gmail.com>
Cc: W_Armin@gmx.de, Hans de Goede <hdegoede@redhat.com>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: wmi: Add Null check for device
Date: Fri, 14 Mar 2025 13:41:42 +0200 (EET)	[thread overview]
Message-ID: <ff53debd-05bd-3a7f-89a5-2110b8103fad@linux.intel.com> (raw)
In-Reply-To: <20250313162820.3688298-1-chenyuan0y@gmail.com>

On Thu, 13 Mar 2025, Chenyuan Yang wrote:

Hi,

Could you please be consistent in style and write "NULL" also in the 
shortlog in the subject.

> Not all devices have an ACPI companion fwnode, so device might be NULL.
> This is similar to the commit cd2fd6eab480
> ("platform/x86: int3472: Check for adev == NULL").

Please fold the paragraph normally.

> Add a check for device not being set and return -ENODEV in that case to
> avoid a possible NULL pointer deref in parse_wdg().
> 
> Note, acpi_wmi_probe() under the same file has such a check.

Hmm, is this a bogus fix, as parse_wdg() is only called from 
acpi_wmi_probe() so how can ACPI companion turn NULL in between??

How was this problem found??

> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
> ---
>  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 646370bd6b03..54e697838c1e 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -1091,6 +1091,9 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)
>  	u32 i, total;
>  	int retval;
>  
> +	if (!device)
> +		return -ENODEV;
> +
>  	status = acpi_evaluate_object(device->handle, "_WDG", NULL, &out);
>  	if (ACPI_FAILURE(status))
>  		return -ENXIO;
> 

-- 
 i.


  reply	other threads:[~2025-03-14 11:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 16:28 [PATCH] platform/x86: wmi: Add Null check for device Chenyuan Yang
2025-03-14 11:41 ` Ilpo Järvinen [this message]
2025-03-14 16:29   ` Chenyuan Yang
2025-03-15 23:56     ` Armin Wolf
2025-03-17 16:07     ` 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=ff53debd-05bd-3a7f-89a5-2110b8103fad@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=W_Armin@gmx.de \
    --cc=chenyuan0y@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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