VSOCK: Return VMCI_ERROR_NO_MEM when fails to allocate skb

vmci_transport_recv_dgram_cb always return VMCI_SUCESS even if we fail
to allocate skb, return VMCI_ERROR_NO_MEM instead.

Signed-off-by: Asias He <asias@redhat.com>
Acked-by: Andy King <acking@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Asias He 2013-06-20 17:20:31 +08:00 committed by David S. Miller
parent b3a6dfe817
commit dce1a28777
1 changed files with 8 additions and 7 deletions

View File

@ -625,13 +625,14 @@ static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg)
/* Attach the packet to the socket's receive queue as an sk_buff. */ /* Attach the packet to the socket's receive queue as an sk_buff. */
skb = alloc_skb(size, GFP_ATOMIC); skb = alloc_skb(size, GFP_ATOMIC);
if (skb) { if (!skb)
/* sk_receive_skb() will do a sock_put(), so hold here. */ return VMCI_ERROR_NO_MEM;
sock_hold(sk);
skb_put(skb, size); /* sk_receive_skb() will do a sock_put(), so hold here. */
memcpy(skb->data, dg, size); sock_hold(sk);
sk_receive_skb(sk, skb, 0); skb_put(skb, size);
} memcpy(skb->data, dg, size);
sk_receive_skb(sk, skb, 0);
return VMCI_SUCCESS; return VMCI_SUCCESS;
} }