Thread (5 messages) 5 messages, 4 authors, 2012-09-06

[patch] virtio-blk: fix NULL checking in virtblk_alloc_req()

STALE5140d

From: Dan Carpenter <hidden>
Date: 2012-09-05 12:32:53
Also in: kernel-janitors
Subsystem: block layer, the rest, virtio block and scsi drivers, virtio core · Maintainers: Jens Axboe, Linus Torvalds, "Michael S. Tsirkin", Jason Wang, Eugenio Pérez

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

Signed-off-by: Dan Carpenter <redacted>
---
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;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help