md: bcache: io.c: fix a potential NULL pointer dereference
authorKumar Amit Mehta <gmate.amit@gmail.com>
Tue, 28 May 2013 07:31:15 +0000 (00:31 -0700)
committerKent Overstreet <koverstreet@google.com>
Thu, 27 Jun 2013 00:06:19 +0000 (17:06 -0700)
bio_alloc_bioset returns NULL on failure. This fix adds a missing check
for potential NULL pointer dereferencing.

Signed-off-by: Kumar Amit Mehta <gmate.amit@gmail.com>
Signed-off-by: Kent Overstreet <koverstreet@google.com>
drivers/md/bcache/io.c

index 48efd4dea645bde1b12cf69927e9f628fd1ae077..d285cd49104c895e75220040007be1d5bf96ad50 100644 (file)
@@ -97,6 +97,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;
        }