md: bcache: io.c: fix a potential NULL pointer dereference
Subsystems (3)
PATCH 1/1 md: bcache: io.c: fix a potential NULL pointer dereference
bio_alloc_bioset returns NULL on failure. This fix adds a missing check for potential NULL pointer dereferencing.
Signed-off-by Kumar Amit Mehta <[email protected]>
--- drivers/md/bcache/io.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/bcache/io.c +2 -0
@@ -98,6 +98,8 @@ struct bio *bch_bio_split(struct bio *bio, int sectors,if (bio->bi_rw &REQ_DISCARD ) { ret =bio_alloc_bioset (gfp,1 , bs); +if (!ret) +return NULL ; idx =0 ; goto out; }
Signature · 1 line
1.7.10.4
Quoted 2 lines · Kumar Amit Mehta
bio_alloc_biosetreturns NULL on failure. This fix adds a missing check for potential NULL pointer dereferencing.
Whoops, that's definitely a bug. Thanks, applied.
How'd you find it?
Quoted 7 lines · Kent Overstreet
Quoted 2 lines · Kumar Amit Mehta
bio_alloc_biosetreturns NULL on failure. This fix adds a missing check for potential NULL pointer dereferencing.Whoops, that's definitely a bug. Thanks, applied.
How'd you find it?
Using smatch[1]