mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+f57d67a92532a98a562d@syzkaller.appspotmail.com
Cc: axboe@kernel.dk, shli@fb.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: [PATCH] nullb: free zones when device is power-off
Date: Fri, 14 Aug 2026 16:21:57 +0800	[thread overview]
Message-ID: <tencent_2E6878C66E4C2CC96EFC9650EA82ECFACF0A@qq.com> (raw)
In-Reply-To: <6a7e5b5b.f70deec7.2acc03.000e.GAE@google.com>

A user powers off the device by writing 0 to `./config/nullb/nullb1/power`
via the nullb configfs interface, and later powers it on by writing 1
to the same file.

When the power-off command is executed, the zones created by the previous
task are not freed before new zones are created upon powering on again;
this results in the memory leak described in [1].

Add an operation to free zones within nullb_device_power_store().

[1]
BUG: memory leak
unreferenced object 0xffff888126990000 (size 56000):
  backtrace (crc 5c9573f8):
    null_init_zoned_dev+0x108/0x520 drivers/block/null_blk/zoned.c:94
    null_add_dev+0x8a6/0xae0 drivers/block/null_blk/main.c:1993
    nullb_device_power_store+0xf9/0x1f0 drivers/block/null_blk/main.c:501
    flush_write_buffer fs/configfs/file.c:207 [inline]
    configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
    new_sync_write fs/read_write.c:595 [inline]
    vfs_write+0x3ac/0x720 fs/read_write.c:687

Fixes: cedcafad8277 ("nullb: add interface to power on disk")
Reported-by: syzbot+f57d67a92532a98a562d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f57d67a92532a98a562d
Tested-by: syzbot+f57d67a92532a98a562d@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 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 f8c0fd57e041..fb001d002d17 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -511,6 +511,7 @@ static ssize_t nullb_device_power_store(struct config_item *item,
 		if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
 			dev->power = newp;
 			null_del_dev(dev->nullb);
+			null_free_zoned_dev(dev);
 		}
 		clear_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
 	}
-- 
2.43.0


  parent reply	other threads:[~2026-08-14  8:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  0:03 [syzbot] [block?] memory leak in null_init_zoned_dev syzbot
2026-08-14  4:50 ` Edward Adam Davis
2026-08-14  8:06   ` syzbot
2026-08-14  8:21 ` Edward Adam Davis [this message]
2026-08-15  2:02   ` [PATCH] nullb: free zones when device is power-off Zizhi Wo

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=tencent_2E6878C66E4C2CC96EFC9650EA82ECFACF0A@qq.com \
    --to=eadavis@qq.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shli@fb.com \
    --cc=syzbot+f57d67a92532a98a562d@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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

all inboxes | Powered by JetHome®