public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Maxim Korotkov <korotkov.maxim.s@gmail.com>,
	Kenneth Chan <kenneth.t.chan@gmail.com>
Cc: Len Brown <len.brown@intel.com>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Harald Welte <laforge@gnumonks.org>,
	Matthew Garrett <mjg@redhat.com>,
	Ivan Kapranov <i.kapranov@securitycode.ru>,
	lvc-project@linuxtesting.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: panasonic-laptop: fix NULL dereference
Date: Thu, 28 Mar 2024 14:53:46 -0700	[thread overview]
Message-ID: <fc085af8-12c0-4885-81e1-453ae203e23e@linux.intel.com> (raw)
In-Reply-To: <20240328103518.169604-1-korotkov.maxim.s@gmail.com>


On 3/28/24 3:35 AM, Maxim Korotkov wrote:
> When initializing the pcc by calling acpi_driver_data(), the "device"
> pointer was dereferenced without checking for NULL. This seems like
> a logical mistake.
>
> Added a pointer check to ensure that it is valid
> before using it for pcc initialization.
>
> Found by Security Code and Linux Verification Center(linuxtesting.org)
>
> Fixes: 709ee531c153 ("panasonic-laptop: add Panasonic Let's Note laptop extras driver v0.94")

Since this is a remove function within kernel, is there any change for
device being NULL?

> Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
> ---
>  drivers/platform/x86/panasonic-laptop.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
> index cf845ee1c7b1..de29758b0384 100644
> --- a/drivers/platform/x86/panasonic-laptop.c
> +++ b/drivers/platform/x86/panasonic-laptop.c
> @@ -1067,9 +1067,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
>  
>  static void acpi_pcc_hotkey_remove(struct acpi_device *device)
>  {
> -	struct pcc_acpi *pcc = acpi_driver_data(device);
> +	struct pcc_acpi *pcc;
>  
> -	if (!device || !pcc)
> +	if (!device)
> +		return;
> +	pcc = acpi_driver_data(device);
> +	if (!pcc)
>  		return;
>  
>  	i8042_remove_filter(panasonic_i8042_filter);

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


  reply	other threads:[~2024-03-28 21:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 10:35 [PATCH] platform/x86: panasonic-laptop: fix NULL dereference Maxim Korotkov
2024-03-28 21:53 ` Kuppuswamy Sathyanarayanan [this message]
2024-03-29  0:21 ` Armin Wolf
2024-03-29  8:20   ` Maxim Korotkov
2024-03-29 18:44     ` Kuppuswamy Sathyanarayanan
2024-04-02 12:36     ` 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=fc085af8-12c0-4885-81e1-453ae203e23e@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=hmh@hmh.eng.br \
    --cc=i.kapranov@securitycode.ru \
    --cc=kenneth.t.chan@gmail.com \
    --cc=korotkov.maxim.s@gmail.com \
    --cc=laforge@gnumonks.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mjg@redhat.com \
    --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