From: Dan Carpenter <dan.carpenter@oracle.com>
To: Asias He <asias@redhat.com>
Cc: kernel-janitors@vger.kernel.org,
virtualization@lists.linux-foundation.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()
Date: Wed, 05 Sep 2012 12:32:53 +0000 [thread overview]
Message-ID: <20120905123252.GE6128@elgon.mountain> (raw)
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;
}
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Asias He <asias@redhat.com>
Cc: kernel-janitors@vger.kernel.org,
virtualization@lists.linux-foundation.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()
Date: Wed, 5 Sep 2012 15:32:53 +0300 [thread overview]
Message-ID: <20120905123252.GE6128@elgon.mountain> (raw)
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;
}
next reply other threads:[~2012-09-05 12:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 12:32 Dan Carpenter [this message]
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-05 13:11 ` Michael S. Tsirkin
2012-09-06 2:55 ` Rusty Russell
2012-09-06 3:07 ` Rusty Russell
2012-09-06 3:04 ` Asias He
2012-09-06 3:04 ` Asias He
2012-09-06 3:02 ` Asias He
2012-09-06 3:02 ` Asias He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120905123252.GE6128@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=asias@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.