diff options
author | Stefano Garzarella <sgarzare@redhat.com> | 2019-05-17 16:45:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-25 18:25:17 +0200 |
commit | 4e539fa2dec4db3405e47002f2878aa4a99eb68b (patch) | |
tree | 7ec824d4e2d0a33baba467547d25fd2912f429f4 /net | |
parent | af4af68df3e48f49a03c2213b8e438ac47143135 (diff) | |
download | linux-stable-4e539fa2dec4db3405e47002f2878aa4a99eb68b.tar.gz linux-stable-4e539fa2dec4db3405e47002f2878aa4a99eb68b.tar.bz2 linux-stable-4e539fa2dec4db3405e47002f2878aa4a99eb68b.zip |
vsock/virtio: free packets during the socket release
[ Upstream commit ac03046ece2b158ebd204dfc4896fd9f39f0e6c8 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/vmw_vsock/virtio_transport_common.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 40a8731c663b..84d3c0aadd73 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -786,12 +786,19 @@ static bool virtio_transport_close(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; bool remove_sock = true; lock_sock(sk); if (sk->sk_type == SOCK_STREAM) 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); if (remove_sock) |