From: Michael S. Tsirkin Date: Thu, 10 Jun 2010 15:16:11 +0000 (+0300) Subject: virtio: return ENOMEM on out of memory X-Git-Tag: v2.6.34.2~204 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e61dcd092ff55415060b37bb4a6cf855385768b9;p=karo-tx-linux.git virtio: return ENOMEM on out of memory commit 686d363786a53ed28ee875b84ef24e6d5126ef6f upstream. add_buf returns ring size on out of memory, this is not what devices expect. Signed-off-by: Michael S. Tsirkin Acked-by: Amit Shah Signed-off-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 0f90634bcb85..6007eba04013 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -118,7 +118,7 @@ static int vring_add_indirect(struct vring_virtqueue *vq, desc = kmalloc((out + in) * sizeof(struct vring_desc), GFP_ATOMIC); if (!desc) - return vq->vring.num; + return -ENOMEM; /* Transfer entries from the sg list into the indirect page */ for (i = 0; i < out; i++) {