Skip to content

Commit

Permalink
vsock: cope with memory allocation failure at socket creation time
Browse files Browse the repository at this point in the history
In the unlikely event that the kmalloc call in vmci_transport_socket_init()
fails, we end-up calling vmci_transport_destruct() with a NULL vmci_trans()
and oopsing.

This change addresses the above explicitly checking for zero vmci_trans()
at destruction time.

Reported-by: Xiumei Mu <[email protected]>
Fixes: d021c34 ("VSOCK: Introduce VM Sockets")
Signed-off-by: Paolo Abeni <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Reviewed-by: Jorgen Hansen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Paolo Abeni authored and davem330 committed Feb 9, 2019
1 parent c09551c commit 225d946
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/vmw_vsock/vmci_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,10 @@ static void vmci_transport_cleanup(struct work_struct *work)

static void vmci_transport_destruct(struct vsock_sock *vsk)
{
/* transport can be NULL if we hit a failure at init() time */
if (!vmci_trans(vsk))
return;

/* Ensure that the detach callback doesn't use the sk/vsk
* we are about to destruct.
*/
Expand Down

0 comments on commit 225d946

Please sign in to comment.