From: Rusty Russell <rusty@rustcorp.com.au>
To: Dan Carpenter <dan.carpenter@oracle.com>, Asias He <asias@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
kernel-janitors@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()
Date: Thu, 06 Sep 2012 03:07:52 +0000 [thread overview]
Message-ID: <871uifj1vr.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20120905123252.GE6128@elgon.mountain>
Dan Carpenter <dan.carpenter@oracle.com> writes:
> 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.
Nice!
> 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;
> }
But it turns out that "vbr->vblk = vblk;" assignment is important :)
Fixed and applied,
Rusty.
WARNING: multiple messages have this Message-ID (diff)
From: Rusty Russell <rusty@rustcorp.com.au>
To: Dan Carpenter <dan.carpenter@oracle.com>, Asias He <asias@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
kernel-janitors@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()
Date: Thu, 06 Sep 2012 12:25:52 +0930 [thread overview]
Message-ID: <871uifj1vr.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20120905123252.GE6128@elgon.mountain>
Dan Carpenter <dan.carpenter@oracle.com> writes:
> 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.
Nice!
> 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;
> }
But it turns out that "vbr->vblk = vblk;" assignment is important :)
Fixed and applied,
Rusty.
next prev parent reply other threads:[~2012-09-06 3:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 12:32 [patch] virtio-blk: fix NULL checking in virtblk_alloc_req() Dan Carpenter
2012-09-05 12:32 ` 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 [this message]
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=871uifj1vr.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=asias@redhat.com \
--cc=dan.carpenter@oracle.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.