Skip to content

Commit 6eb0968

Browse files
johnpgarryaxboe
authored andcommitted
block: Handle bio_split() errors in bio_submit_split()
bio_split() may error, so check this. Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 27b26f0 commit 6eb0968

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

block/blk-merge.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,18 @@ static unsigned int bio_allowed_max_sectors(const struct queue_limits *lim)
107107

108108
static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
109109
{
110-
if (unlikely(split_sectors < 0)) {
111-
bio->bi_status = errno_to_blk_status(split_sectors);
112-
bio_endio(bio);
113-
return NULL;
114-
}
110+
if (unlikely(split_sectors < 0))
111+
goto error;
115112

116113
if (split_sectors) {
117114
struct bio *split;
118115

119116
split = bio_split(bio, split_sectors, GFP_NOIO,
120117
&bio->bi_bdev->bd_disk->bio_split);
118+
if (IS_ERR(split)) {
119+
split_sectors = PTR_ERR(split);
120+
goto error;
121+
}
121122
split->bi_opf |= REQ_NOMERGE;
122123
blkcg_bio_issue_init(split);
123124
bio_chain(split, bio);
@@ -128,6 +129,10 @@ static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
128129
}
129130

130131
return bio;
132+
error:
133+
bio->bi_status = errno_to_blk_status(split_sectors);
134+
bio_endio(bio);
135+
return NULL;
131136
}
132137

133138
struct bio *bio_split_discard(struct bio *bio, const struct queue_limits *lim,

0 commit comments

Comments
 (0)