summaryrefslogtreecommitdiffstats
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-09-05 15:32:53 +0300
committerRusty Russell <rusty@rustcorp.com.au>2012-09-28 15:05:14 +0930
commitf22cf8eb485260ac6e32a614121d44998d83a69a (patch)
tree9dd48f6f12bff4615f4c1a8eff8cdb13b2175ee6 /drivers/block/virtio_blk.c
parentc85a1f91b393a6c0c2ad382ba59d7618b29ab758 (diff)
downloadtalos-op-linux-f22cf8eb485260ac6e32a614121d44998d83a69a.tar.gz
talos-op-linux-f22cf8eb485260ac6e32a614121d44998d83a69a.zip
virtio-blk: fix NULL checking in virtblk_alloc_req()
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)
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r--drivers/block/virtio_blk.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 2edfb5cef4f2..53b81d59059b 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -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;
}
OpenPOWER on IntegriCloud