Skip to content

Commit

Permalink
virtio-blk: fix NULL checking in virtblk_alloc_req()
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Dan Carpenter authored and Rusty Russell committed Sep 28, 2012
1 parent c85a1f9 commit f22cf8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f22cf8e

Please sign in to comment.