virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()
@ 2012-09-05 12:32 Dan Carpenter
  2012-09-05 13:11 ` Michael S. Tsirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-09-05 12:32 UTC (permalink / raw)
  To: Asias He; +Cc: kernel-janitors, virtualization, Michael S. Tsirkin

Smatch complains about the inconsistent NULL checking here.  Fix it to
return NULL on failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is only needed in linux-next.

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 2edfb5c..457db0c 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -90,10 +90,11 @@ 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;
 }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-06  3:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 12:32 [patch] virtio-blk: fix NULL checking in virtblk_alloc_req() Dan Carpenter
2012-09-05 13:11 ` Michael S. Tsirkin
2012-09-06  2:55 ` Rusty Russell
2012-09-06  3:04   ` Asias He
2012-09-06  3:02 ` Asias He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).