Skip to content

Commit

Permalink
md: bcache: check the return value of kzalloc() in detached_dev_do_re…
Browse files Browse the repository at this point in the history
…quest()

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 <[email protected]>
Signed-off-by: Jia-Ju Bai <[email protected]>
Signed-off-by: Coly Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
XidianGeneral authored and axboe committed May 27, 2022
1 parent 7d6b902 commit 40f567b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/md/bcache/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,12 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
* which would call closure_get(&dc->disk.cl)
*/
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
if (!ddip) {
bio->bi_status = BLK_STS_RESOURCE;
bio->bi_end_io(bio);
return;
}

ddip->d = d;
/* Count on the bcache device */
ddip->orig_bdev = orig_bdev;
Expand Down

0 comments on commit 40f567b

Please sign in to comment.