]>
Commit | Line | Data |
---|---|---|
9e23bb9f GKH |
1 | From foo@baz Wed 22 May 2019 06:53:31 PM CEST |
2 | From: Stefano Garzarella <sgarzare@redhat.com> | |
3 | Date: Fri, 17 May 2019 16:45:43 +0200 | |
4 | Subject: vsock/virtio: free packets during the socket release | |
5 | ||
6 | From: Stefano Garzarella <sgarzare@redhat.com> | |
7 | ||
8 | [ Upstream commit ac03046ece2b158ebd204dfc4896fd9f39f0e6c8 ] | |
9 | ||
10 | When the socket is released, we should free all packets | |
11 | queued in the per-socket list in order to avoid a memory | |
12 | leak. | |
13 | ||
14 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> | |
15 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
16 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
17 | --- | |
18 | net/vmw_vsock/virtio_transport_common.c | 7 +++++++ | |
19 | 1 file changed, 7 insertions(+) | |
20 | ||
21 | --- a/net/vmw_vsock/virtio_transport_common.c | |
22 | +++ b/net/vmw_vsock/virtio_transport_common.c | |
23 | @@ -725,12 +725,19 @@ static bool virtio_transport_close(struc | |
24 | ||
25 | void virtio_transport_release(struct vsock_sock *vsk) | |
26 | { | |
27 | + struct virtio_vsock_sock *vvs = vsk->trans; | |
28 | + struct virtio_vsock_pkt *pkt, *tmp; | |
29 | struct sock *sk = &vsk->sk; | |
30 | bool remove_sock = true; | |
31 | ||
32 | lock_sock(sk); | |
33 | if (sk->sk_type == SOCK_STREAM) | |
34 | remove_sock = virtio_transport_close(vsk); | |
35 | + | |
36 | + list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) { | |
37 | + list_del(&pkt->list); | |
38 | + virtio_transport_free_pkt(pkt); | |
39 | + } | |
40 | release_sock(sk); | |
41 | ||
42 | if (remove_sock) |