]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: fix memory leak in __blkdev_issue_zero_pages
authorShaurya Rane <ssrane_b23@ee.vjti.ac.in>
Thu, 4 Dec 2025 18:12:59 +0000 (23:42 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:36 +0000 (14:03 +0100)
commit7193407bc4457212fa38ec3aff9c640e63a8dbef
treed3defc56ae178c8214b736ed64864034b524a333
parent2864db01b3e54ae441b15bfb65f342e69e51140b
block: fix memory leak in __blkdev_issue_zero_pages

[ Upstream commit f7e3f852a42d7cd8f1af2c330d9d153e30c8adcf ]

Move the fatal signal check before bio_alloc() to prevent a memory
leak when BLKDEV_ZERO_KILLABLE is set and a fatal signal is pending.

Previously, the bio was allocated before checking for a fatal signal.
If a signal was pending, the code would break out of the loop without
freeing or chaining the just-allocated bio, causing a memory leak.

This matches the pattern already used in __blkdev_issue_write_zeroes()
where the signal check precedes the allocation.

Fixes: bf86bcdb4012 ("blk-lib: check for kill signal in ioctl BLKZEROOUT")
Reported-by: syzbot+527a7e48a3d3d315d862@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=527a7e48a3d3d315d862
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Tested-by: syzbot+527a7e48a3d3d315d862@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-lib.c