Skip to content

Commit 20bbe5b

Browse files
author
Paolo Abeni
committed
Merge branch 'virtio-vsock-fix-memory-leaks'
Michal Luczaj says: ==================== virtio/vsock: Fix memory leaks Short series fixing some memory leaks that I've stumbled upon while toying with the selftests. Signed-off-by: Michal Luczaj <[email protected]> ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 76d71ee + 60cf620 commit 20bbe5b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,9 @@ static void vsock_sk_destruct(struct sock *sk)
836836
{
837837
struct vsock_sock *vsk = vsock_sk(sk);
838838

839+
/* Flush MSG_ZEROCOPY leftovers. */
840+
__skb_queue_purge(&sk->sk_error_queue);
841+
839842
vsock_deassign_transport(vsk);
840843

841844
/* When clearing these addresses, there's no need to set the family and

net/vmw_vsock/virtio_transport_common.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
400400
if (virtio_transport_init_zcopy_skb(vsk, skb,
401401
info->msg,
402402
can_zcopy)) {
403+
kfree_skb(skb);
403404
ret = -ENOMEM;
404405
break;
405406
}
@@ -1512,6 +1513,14 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
15121513
return -ENOMEM;
15131514
}
15141515

1516+
/* __vsock_release() might have already flushed accept_queue.
1517+
* Subsequent enqueues would lead to a memory leak.
1518+
*/
1519+
if (sk->sk_shutdown == SHUTDOWN_MASK) {
1520+
virtio_transport_reset_no_sock(t, skb);
1521+
return -ESHUTDOWN;
1522+
}
1523+
15151524
child = vsock_create_connected(sk);
15161525
if (!child) {
15171526
virtio_transport_reset_no_sock(t, skb);

0 commit comments

Comments
 (0)