]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
virtio-blk: fix NULL checking in virtblk_alloc_req()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 5 Sep 2012 12:32:53 +0000 (15:32 +0300)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Sep 2012 00:33:31 +0000 (10:33 +1000)
Smatch complains about the inconsistent NULL checking here.  Fix it to
return NULL on failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (fixed accidental deletion)
drivers/block/virtio_blk.c

index 2edfb5cef4f2126631ee42f1dcd5f0d55e08313b..53b81d59059b5d4074b582aab6432ccdba42e79b 100644 (file)
@@ -90,10 +90,12 @@ static inline struct virtblk_req *virtblk_alloc_req(struct virtio_blk *vblk,
        struct virtblk_req *vbr;
 
        vbr = mempool_alloc(vblk->pool, gfp_mask);
-       if (vbr && use_bio)
-               sg_init_table(vbr->sg, vblk->sg_elems);
+       if (!vbr)
+               return NULL;
 
        vbr->vblk = vblk;
+       if (use_bio)
+               sg_init_table(vbr->sg, vblk->sg_elems);
 
        return vbr;
 }