From: Dan Carpenter Date: Wed, 5 Sep 2012 12:32:53 +0000 (+0300) Subject: virtio-blk: fix NULL checking in virtblk_alloc_req() X-Git-Tag: next-20120920~61^2~9 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2419963547178fd61a90c6fdd1c98ce63d15e75e;p=karo-tx-linux.git 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 Signed-off-by: Rusty Russell (fixed accidental deletion) --- 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; }