Commit 7d29c9ad authored by Stefano Garzarella's avatar Stefano Garzarella Committed by Greg Kroah-Hartman

vsock/virtio: free packets during the socket release

[ Upstream commit ac03046e ]

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: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4f747a79
...@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk) ...@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk)
void virtio_transport_release(struct vsock_sock *vsk) void virtio_transport_release(struct vsock_sock *vsk)
{ {
struct virtio_vsock_sock *vvs = vsk->trans;
struct virtio_vsock_pkt *pkt, *tmp;
struct sock *sk = &vsk->sk; struct sock *sk = &vsk->sk;
bool remove_sock = true; bool remove_sock = true;
lock_sock(sk); lock_sock(sk);
if (sk->sk_type == SOCK_STREAM) if (sk->sk_type == SOCK_STREAM)
remove_sock = virtio_transport_close(vsk); remove_sock = virtio_transport_close(vsk);
list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) {
list_del(&pkt->list);
virtio_transport_free_pkt(pkt);
}
release_sock(sk); release_sock(sk);
if (remove_sock) if (remove_sock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment