Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2189358ybm; Thu, 23 May 2019 12:50:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEBZJAhKBCFQsdhUtdxPCNZvJToJANJBsoQc6EB2Fv6O1YtDwXtyXrIdm+vxR+lCuPWiaQ X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr3844690pjr.91.1558641036393; Thu, 23 May 2019 12:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558641036; cv=none; d=google.com; s=arc-20160816; b=0gjcNK7fdVs2zk7qEcgbPIzLqCtmjSsBY9fAcU2jNDi/Lf/Jw3dW6qRtKWwzGX6CeX R/zjAJaI+mhpmGJ5i1gaK2oT/WSgp/GI0djX+IWoUovF0MJiO/QI1bZ/dYMGKUhUYHcO g2qYie9SJjnoWzLNbgf+Y05HxnBmK9pCSyypmonz+6VzguFHFMkmS6SRmTXaYm9eYd1Z h8JcA982kz2xo2ycN6/YcYS2ot6nq1RFpWmilFdXm5pWt6CbW9h18SvBUje8eS2usJY6 j1JEdPLGNhzDVgIJEAjrBiqfYR4XQDPFX4u+U+I22AcoU0aMmHDNZg0RkuuylvxdF8lo bhbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KrW40nRXJNl7koO9qP2PLLCIw5A9j9wgKf8YsaRCDa0=; b=DKeF5CYtyJNa7YLf6CfYvsoNk4bSAfDbrrgHD0TlTcWy0QWjPhpg/7kkNf7LEAm+Qg si2D9bnKr0WbQcyDJktg9iKQgQqSjWtlspSg+sO9/qelMtgkJlBZbMyzUtrXFUpt6Gg1 XfadtTZveq+gZR/BXif0nRqUbmAdDk1HxkrJLPaD+xkJqUDju6ngn8LD+zJyw8vNGWMV PH7Wa3eeZibV8npLk6dT1jjaf+LthApzJmsViLMMJD3B5cTog/GFtgN7d3dkD8u1+w2T PwSMCmL61RGzIz1W65RD34HMv7Sq5RgZp7iKPq9tk1nRYf71pfeIpfNlbb2ap3nnOmjV U6kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QrENA8Uc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b186si331743pfa.255.2019.05.23.12.50.21; Thu, 23 May 2019 12:50:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QrENA8Uc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731666AbfEWTtT (ORCPT + 99 others); Thu, 23 May 2019 15:49:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388069AbfEWTLK (ORCPT ); Thu, 23 May 2019 15:11:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6C712217D9; Thu, 23 May 2019 19:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638669; bh=tQ4EPmHa88YeE+lsAVf8RF8bcxRpc2MVqWookuBRWD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QrENA8UcnVJIM6yfJF3PMxexITSAcuIwkdpnFKOwaeREa2pIPbH7rBIkDElTCs3G9 XGz0qzoxmQi/kgxn+50lbldLdJu4ej8Jef1vq1KDQxv17nMg3QBzpOift3FEE9qrF1 ANHT6kOEpV1eKXxZmmgY5ZzvjCSp4bvbf4BpPyeI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Garzarella , "David S. Miller" Subject: [PATCH 4.14 07/77] vsock/virtio: free packets during the socket release Date: Thu, 23 May 2019 21:05:25 +0200 Message-Id: <20190523181721.098201875@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefano Garzarella [ 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/vmw_vsock/virtio_transport_common.c | 7 +++++++ 1 file changed, 7 insertions(+) --- 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(struc 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)