Skip to contentSkip to conversation

md: bcache: io.c: fix a potential NULL pointer dereference

PATCH In review Kumar Amit Mehta 2 participants 3 messages May 28, 2013 – May 29, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

---
 drivers/md/bcache/io.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/md/bcache/io.c +2 -0
index 29f344b..4be2a07 100644
@@ -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
#1 lore raw
Quoted 2 lines · Kumar Amit Mehta

bio_alloc_bioset returns 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?

#2 lore raw
Quoted 7 lines · Kent Overstreet
Quoted 2 lines · Kumar Amit Mehta

bio_alloc_bioset returns 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]

[1] http://smatch.sourceforge.net/