LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Darren Hart <dvhart@infradead.org>
To: "João Paulo Rechi Vita" <jprvita@gmail.com>
Cc: "Corentin Chary" <corentin.chary@gmail.com>,
	"Andy Shevchenko" <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org,
	acpi4asus-user@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, linux@endlessm.com,
	"Dun Hum" <bitter.taste@gmx.com>,
	"João Paulo Rechi Vita" <jprvita@endlessm.com>
Subject: Re: [PATCH] platform/x86: asus-wireless: Fix NULL pointer dereference
Date: Sat, 7 Apr 2018 08:50:06 -0700	[thread overview]
Message-ID: <20180407155006.GA11256@fury> (raw)
In-Reply-To: <20180407053729.5434-1-jprvita@endlessm.com>

On Fri, Apr 06, 2018 at 10:37:29PM -0700, João Paulo Rechi Vita wrote:
> When the module is removed the led workqueue is destroyed in the remove
> callback, before the led device is unregistered from the led subsystem.
> 
> This leads to a NULL pointer derefence when the led device is
> unregistered automatically later as part of the module removal cleanup.
> Bellow is the backtrace showing the problem.
> 

Thanks João Paulo,
...

> Unregistering the led device on the remove callback before destroying the
> workqueue avoids this problem.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=196097
> 
> Reported-by: Dun Hum <bitter.taste@gmx.com>
> Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
> ---
>  drivers/platform/x86/asus-wireless.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
> index 343e12547660..ecd715c82de5 100644
> --- a/drivers/platform/x86/asus-wireless.c
> +++ b/drivers/platform/x86/asus-wireless.c
> @@ -181,6 +181,7 @@ static int asus_wireless_remove(struct acpi_device *adev)
>  {
>  	struct asus_wireless_data *data = acpi_driver_data(adev);
>  
> +	devm_led_classdev_unregister(&adev->dev, &data->led);
>  	if (data->wq)
>  		destroy_workqueue(data->wq);
>  	return 0;

asus_wireless_add only calls devm_led_classdev_register() iff the workqueue is
successfully created. It seems like it would make sense to move the
devm_led_classdev_unregister() call within the 'if (data->wq)' condition block.

This should also cc stable.

Thanks,

-- 
Darren Hart
VMware Open Source Technology Center

  reply	other threads:[~2018-04-07 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07  5:37 João Paulo Rechi Vita
2018-04-07 15:50 ` Darren Hart [this message]
2018-04-19 13:59   ` João Paulo Rechi Vita
2018-04-19 14:04     ` [PATCH v2] " João Paulo Rechi Vita
2018-04-19 23:49       ` Darren Hart

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=20180407155006.GA11256@fury \
    --to=dvhart@infradead.org \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=andy@infradead.org \
    --cc=bitter.taste@gmx.com \
    --cc=corentin.chary@gmail.com \
    --cc=jprvita@endlessm.com \
    --cc=jprvita@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@endlessm.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --subject='Re: [PATCH] platform/x86: asus-wireless: Fix NULL pointer dereference' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).