Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bdccaa5 authored by Igor Druzhinin's avatar Igor Druzhinin Committed by Greg Kroah-Hartman
Browse files

xen-netback: fix memory leaks on XenBus disconnect




[ Upstream commit 9a6cdf52b85ea5fb21d2bb31e4a7bc61b79923a7 ]

Eliminate memory leaks introduced several years ago by cleaning the
queue resources which are allocated on XenBus connection event. Namely, queue
structure array and pages used for IO rings.

Signed-off-by: default avatarIgor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: default avatarPaul Durrant <paul.durrant@citrix.com>
Acked-by: default avatarWei Liu <wei.liu2@citrix.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5dcd0859
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -493,11 +493,20 @@ static int backend_create_xenvif(struct backend_info *be)
static void backend_disconnect(struct backend_info *be)
{
	if (be->vif) {
		unsigned int queue_index;

		xen_unregister_watchers(be->vif);
#ifdef CONFIG_DEBUG_FS
		xenvif_debugfs_delif(be->vif);
#endif /* CONFIG_DEBUG_FS */
		xenvif_disconnect_data(be->vif);
		for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index)
			xenvif_deinit_queue(&be->vif->queues[queue_index]);

		vfree(be->vif->queues);
		be->vif->num_queues = 0;
		be->vif->queues = NULL;

		xenvif_disconnect_ctrl(be->vif);
	}
}
@@ -1040,6 +1049,8 @@ static void connect(struct backend_info *be)
err:
	if (be->vif->num_queues > 0)
		xenvif_disconnect_data(be->vif); /* Clean up existing queues */
	for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index)
		xenvif_deinit_queue(&be->vif->queues[queue_index]);
	vfree(be->vif->queues);
	be->vif->queues = NULL;
	be->vif->num_queues = 0;