Skip to content

Commit 40f567b

Browse files
XidianGeneralaxboe
authored andcommitted
md: bcache: check the return value of kzalloc() in detached_dev_do_request()
The function kzalloc() in detached_dev_do_request() can fail, so its return value should be checked. Fixes: bc082a5 ("bcache: fix inaccurate io state for detached bcache devices") Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Coly Li <colyli@suse.de> Link: https://lore.kernel.org/r/20220527152818.27545-4-colyli@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7d6b902 commit 40f567b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/md/bcache/request.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,12 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
11051105
* which would call closure_get(&dc->disk.cl)
11061106
*/
11071107
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
1108+
if (!ddip) {
1109+
bio->bi_status = BLK_STS_RESOURCE;
1110+
bio->bi_end_io(bio);
1111+
return;
1112+
}
1113+
11081114
ddip->d = d;
11091115
/* Count on the bcache device */
11101116
ddip->orig_bdev = orig_bdev;

0 commit comments

Comments
 (0)