Skip to content

Commit

Permalink
VSOCK: Return VMCI_ERROR_NO_MEM when fails to allocate skb
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Asias He authored and davem330 committed Jun 24, 2013
1 parent b3a6dfe commit dce1a28
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions net/vmw_vsock/vmci_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
skb = alloc_skb(size, GFP_ATOMIC);
if (skb) {
/* sk_receive_skb() will do a sock_put(), so hold here. */
sock_hold(sk);
skb_put(skb, size);
memcpy(skb->data, dg, size);
sk_receive_skb(sk, skb, 0);
}
if (!skb)
return VMCI_ERROR_NO_MEM;

/* sk_receive_skb() will do a sock_put(), so hold here. */
sock_hold(sk);
skb_put(skb, size);
memcpy(skb->data, dg, size);
sk_receive_skb(sk, skb, 0);

return VMCI_SUCCESS;
}
Expand Down

0 comments on commit dce1a28

Please sign in to comment.