Skip to content

Commit ac03046

Browse files
stefano-garzarelladavem330
authored andcommitted
vsock/virtio: free packets during the socket release
When the socket is released, we should free all packets queued in the per-socket list in order to avoid a memory leak. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 532b0f7 commit ac03046

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/vmw_vsock/virtio_transport_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk)
786786

787787
void virtio_transport_release(struct vsock_sock *vsk)
788788
{
789+
struct virtio_vsock_sock *vvs = vsk->trans;
790+
struct virtio_vsock_pkt *pkt, *tmp;
789791
struct sock *sk = &vsk->sk;
790792
bool remove_sock = true;
791793

792794
lock_sock(sk);
793795
if (sk->sk_type == SOCK_STREAM)
794796
remove_sock = virtio_transport_close(vsk);
797+
798+
list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) {
799+
list_del(&pkt->list);
800+
virtio_transport_free_pkt(pkt);
801+
}
795802
release_sock(sk);
796803

797804
if (remove_sock)

0 commit comments

Comments
 (0)