Skip to content

Commit 9af149c

Browse files
ncroxongregkh
authored andcommitted
raid10: cleanup memleak at raid10_make_request
[ Upstream commit 43806c3d5b9bb7d74ba4e33a6a8a41ac988bde24 ] If raid10_read_request or raid10_write_request registers a new request and the REQ_NOWAIT flag is set, the code does not free the malloc from the mempool. unreferenced object 0xffff8884802c3200 (size 192): comm "fio", pid 9197, jiffies 4298078271 hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 88 41 02 00 00 00 00 00 .........A...... 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc c1a049a2): __kmalloc+0x2bb/0x450 mempool_alloc+0x11b/0x320 raid10_make_request+0x19e/0x650 [raid10] md_handle_request+0x3b3/0x9e0 __submit_bio+0x394/0x560 __submit_bio_noacct+0x145/0x530 submit_bio_noacct_nocheck+0x682/0x830 __blkdev_direct_IO_async+0x4dc/0x6b0 blkdev_read_iter+0x1e5/0x3b0 __io_read+0x230/0x1110 io_read+0x13/0x30 io_issue_sqe+0x134/0x1180 io_submit_sqes+0x48c/0xe90 __do_sys_io_uring_enter+0x574/0x8b0 do_syscall_64+0x5c/0xe0 entry_SYSCALL_64_after_hwframe+0x76/0x7e V4: changing backing tree to see if CKI tests will pass. The patch code has not changed between any versions. Fixes: c9aa889 ("md: raid10 add nowait support") Signed-off-by: Nigel Croxon <[email protected]> Link: https://lore.kernel.org/linux-raid/[email protected] Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5f35e48 commit 9af149c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/md/raid10.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,11 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
12101210
rcu_read_unlock();
12111211
}
12121212

1213-
if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors))
1213+
if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors)) {
1214+
raid_end_bio_io(r10_bio);
12141215
return;
1216+
}
1217+
12151218
rdev = read_balance(conf, r10_bio, &max_sectors);
12161219
if (!rdev) {
12171220
if (err_rdev) {
@@ -1432,8 +1435,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
14321435
}
14331436

14341437
sectors = r10_bio->sectors;
1435-
if (!regular_request_wait(mddev, conf, bio, sectors))
1438+
if (!regular_request_wait(mddev, conf, bio, sectors)) {
1439+
raid_end_bio_io(r10_bio);
14361440
return;
1441+
}
1442+
14371443
if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
14381444
(mddev->reshape_backwards
14391445
? (bio->bi_iter.bi_sector < conf->reshape_safe &&

0 commit comments

Comments
 (0)