* [PATCH v3] vsock/virtio: free packets during the socket release
@ 2019-05-17 14:45 Stefano Garzarella
2019-05-17 18:47 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Garzarella @ 2019-05-17 14:45 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, virtualization, linux-kernel, kvm,
Stefan Hajnoczi, stable
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>
---
This patch was in the series "[PATCH v2 0/8] vsock/virtio: optimizations
to increase the throughput" [1]. As Stefan suggested, I'm sending it as
a separated patch.
v3:
- use list_for_each_entry_safe() [David]
[1] https://patchwork.kernel.org/cover/10938743/
---
net/vmw_vsock/virtio_transport_common.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 602715fc9a75..f3f3d06cb6d8 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)
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] vsock/virtio: free packets during the socket release
2019-05-17 14:45 [PATCH v3] vsock/virtio: free packets during the socket release Stefano Garzarella
@ 2019-05-17 18:47 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-05-17 18:47 UTC (permalink / raw)
To: sgarzare; +Cc: netdev, virtualization, linux-kernel, kvm, stefanha, stable
From: Stefano Garzarella <sgarzare@redhat.com>
Date: Fri, 17 May 2019 16:45:43 +0200
> 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>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-17 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 14:45 [PATCH v3] vsock/virtio: free packets during the socket release Stefano Garzarella
2019-05-17 18:47 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).