Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Shang XiaoJing <shangxiaojing@huawei.com>, linux-parisc@vger.kernel.org
Subject: Re: [PATCH] parisc: led: Fix potential null-ptr-deref in start_task()
Date: Fri, 18 Nov 2022 07:42:35 +0100	[thread overview]
Message-ID: <c8ff1b4a-485a-94c9-a488-ed323e12c165@gmx.de> (raw)
In-Reply-To: <20221117024514.3620-1-shangxiaojing@huawei.com>

On 11/17/22 03:45, Shang XiaoJing wrote:
> start_task() calls create_singlethread_workqueue() and not checked the
> ret value, which may return NULL. And a null-ptr-deref may happen:
>
> start_task()
>      create_singlethread_workqueue() # failed, led_wq is NULL
>      queue_delayed_work()
>          queue_delayed_work_on()
>              __queue_delayed_work()  # warning here, but continue
>                  __queue_work()      # access wq->flags, null-ptr-deref
>
> Check the ret value and return -ENOMEM if it is NULL.
>
> Fixes: 3499495205a6 ("[PARISC] Use work queue in LED/LCD driver instead of tasklet.")
> Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>

applied.

Thanks!
Helge

> ---
>   drivers/parisc/led.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
> index d4be9d2ee74d..8bdc5e043831 100644
> --- a/drivers/parisc/led.c
> +++ b/drivers/parisc/led.c
> @@ -137,6 +137,9 @@ static int start_task(void)
>
>   	/* Create the work queue and queue the LED task */
>   	led_wq = create_singlethread_workqueue("led_wq");
> +	if (!led_wq)
> +		return -ENOMEM;
> +
>   	queue_delayed_work(led_wq, &led_task, 0);
>
>   	return 0;


      reply	other threads:[~2022-11-18  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  2:45 [PATCH] parisc: led: Fix potential null-ptr-deref in start_task() Shang XiaoJing
2022-11-18  6:42 ` Helge Deller [this message]

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=c8ff1b4a-485a-94c9-a488-ed323e12c165@gmx.de \
    --to=deller@gmx.de \
    --cc=linux-parisc@vger.kernel.org \
    --cc=shangxiaojing@huawei.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