From: Shang XiaoJing <shangxiaojing@huawei.com>
To: <James.Bottomley@HansenPartnership.com>, <deller@gmx.de>,
<grundler@parisc-linux.org>, <kyle@parisc-linux.org>,
<linux-parisc@vger.kernel.org>
Cc: <shangxiaojing@huawei.com>
Subject: [PATCH] parisc: led: Fix potential null-ptr-deref in start_task()
Date: Thu, 17 Nov 2022 10:45:14 +0800 [thread overview]
Message-ID: <20221117024514.3620-1-shangxiaojing@huawei.com> (raw)
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>
---
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;
--
2.17.1
next reply other threads:[~2022-11-17 2:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 2:45 Shang XiaoJing [this message]
2022-11-18 6:42 ` [PATCH] parisc: led: Fix potential null-ptr-deref in start_task() Helge Deller
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=20221117024514.3620-1-shangxiaojing@huawei.com \
--to=shangxiaojing@huawei.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=deller@gmx.de \
--cc=grundler@parisc-linux.org \
--cc=kyle@parisc-linux.org \
--cc=linux-parisc@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