From: Miroslav Cimerman <mc@raidlab.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Miroslav Cimerman <mc@raidlab.org>
Subject: [PATCH] null_blk: reset throttled state before device setup
Date: Thu, 5 Nov 2026 01:42:45 +0000 [thread overview]
Message-ID: <20261105014245.436826-1-mc@raidlab.org> (raw)
The NULLB_DEV_FL_THROTTLED flag is set at power on when mbps is set, and
is never cleared. Since commit 00a8cdb84fcb ("null_blk: remove
NULLB_DEV_FL_CONFIGURED on turning off nullb device") mbps can change
when the device is off. After a change to 0, the stale THROTTLED flag
sends I/O into the throttled I/O handler, whose hrtimer_active() runs on
an uninitialized timer, dereferencing a NULL pointer. A crash happens at
power on, as the first I/O that triggers the NULL dereference is
partition scanning I/O. This sequence triggers the crash:
echo 100 > mbps; echo 1 > power; echo 0 > power; echo 0 > mbps;
echo 1 > power
Clear the flag at the start of null_add_dev(), as is done in commit
5a4236bf2262 ("null_blk: reset cache state before device setup") for
NULLB_DEV_FL_CACHE. It is set again when mbps is set.
Fixes: 00a8cdb84fcb ("null_blk: remove NULLB_DEV_FL_CONFIGURED on turning off nullb device")
Signed-off-by: Miroslav Cimerman <mc@raidlab.org>
---
drivers/block/null_blk/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index ec0d7ba4d938..924ec6cfdcaa 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1977,6 +1977,7 @@ static int null_add_dev(struct nullb_device *dev)
if (rv)
return rv;
clear_bit(NULLB_DEV_FL_CACHE, &dev->flags);
+ clear_bit(NULLB_DEV_FL_THROTTLED, &dev->flags);
nullb = kzalloc_node(sizeof(*nullb), GFP_KERNEL, dev->home_node);
if (!nullb) {
base-commit: e6ac1da6a53c5f670bf09e60a2500d15be68d2fc
--
2.53.0
reply other threads:[~2026-11-05 1:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261105014245.436826-1-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®