diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-07-26 16:55:30 +0930 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-02 10:29:51 -0700 |
commit | c558ea6dff2c2efe3329d95bbadd9cdad272dc6d (patch) | |
tree | 62df080dbc918541c7978add42a5ed25c2160cfe /drivers | |
parent | 0094153a72107b3097818f1221c1f49c2eb0db90 (diff) | |
download | lwn-c558ea6dff2c2efe3329d95bbadd9cdad272dc6d.tar.gz lwn-c558ea6dff2c2efe3329d95bbadd9cdad272dc6d.zip |
virtio: fix oops on OOM
commit 1fe9b6fef11771461e69ecd1bc8935a1c7c90cb5 upstream.
virtio ring was changed to return an error code on OOM,
but one caller was missed and still checks for vq->vring.num.
The fix is just to check for <0 error code.
Long term it might make sense to change goto add_head to
just return an error on oom instead, but let's apply
a minimal fix for 2.6.35.
Reported-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 6007eba04013..dd4370b45763 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -162,7 +162,8 @@ static int vring_add_buf(struct virtqueue *_vq, void *data) { struct vring_virtqueue *vq = to_vvq(_vq); - unsigned int i, avail, head, uninitialized_var(prev); + unsigned int i, avail, uninitialized_var(prev); + int head; START_USE(vq); @@ -172,7 +173,7 @@ static int vring_add_buf(struct virtqueue *_vq, * buffers, then go indirect. FIXME: tune this threshold */ if (vq->indirect && (out + in) > 1 && vq->num_free) { head = vring_add_indirect(vq, sg, out, in); - if (head != vq->vring.num) + if (likely(head >= 0)) goto add_head; } |