Commit 20bbe5b8 authored by Paolo Abeni's avatar Paolo Abeni
Browse files

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: default avatarMichal Luczaj <mhal@rbox.co>
====================

Link: https://patch.msgid.link/20241107-vsock-mem-leaks-v2-0-4e21bfcfc818@rbox.co


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 76d71eee 60cf6206
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -836,6 +836,9 @@ static void vsock_sk_destruct(struct sock *sk)
{
	struct vsock_sock *vsk = vsock_sk(sk);

	/* Flush MSG_ZEROCOPY leftovers. */
	__skb_queue_purge(&sk->sk_error_queue);

	vsock_deassign_transport(vsk);

	/* When clearing these addresses, there's no need to set the family and
+9 −0
Original line number Diff line number Diff line
@@ -400,6 +400,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
			if (virtio_transport_init_zcopy_skb(vsk, skb,
							    info->msg,
							    can_zcopy)) {
				kfree_skb(skb);
				ret = -ENOMEM;
				break;
			}
@@ -1512,6 +1513,14 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
		return -ENOMEM;
	}

	/* __vsock_release() might have already flushed accept_queue.
	 * Subsequent enqueues would lead to a memory leak.
	 */
	if (sk->sk_shutdown == SHUTDOWN_MASK) {
		virtio_transport_reset_no_sock(t, skb);
		return -ESHUTDOWN;
	}

	child = vsock_create_connected(sk);
	if (!child) {
		virtio_transport_reset_no_sock(t, skb);