]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/vmw_vsock/vmci_transport.c
VSOCK: Return VMCI_ERROR_NO_MEM when fails to allocate skb
[karo-tx-linux.git] / net / vmw_vsock / vmci_transport.c
index daff75200e256705b3e0e9605cf6e6baf6ac17e3..99b511ddb4cba15b1a323b1284002c988c0dd598 100644 (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. */
        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;
 }