Commit 2ddbcea7 authored by David S. Miller's avatar David S. Miller

Merge branch 'xen-netback-fixes'

Paul Durrant says:

====================
xen-netback: update memory leak fix to avoid BUG

Commit 9a6cdf52 "xen-netback: fix memory leaks on XenBus disconnect"
added missing code to fix a memory leak by calling vfree() in the
appropriate place.
Unfortunately subsequent commit f16f1df6 "xen-netback: protect
resource cleaning on XenBus disconnect" then wrapped this call to vfree()
in a spin lock, leading to a BUG due to incorrect context.

Patch #1 makes the existing code more readable
Patch #2 fixes the problem
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f7bb3d86 a254d8f9
...@@ -492,24 +492,31 @@ static int backend_create_xenvif(struct backend_info *be) ...@@ -492,24 +492,31 @@ static int backend_create_xenvif(struct backend_info *be)
static void backend_disconnect(struct backend_info *be) static void backend_disconnect(struct backend_info *be)
{ {
if (be->vif) { struct xenvif *vif = be->vif;
if (vif) {
unsigned int queue_index; unsigned int queue_index;
struct xenvif_queue *queues;
xen_unregister_watchers(be->vif); xen_unregister_watchers(vif);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
xenvif_debugfs_delif(be->vif); xenvif_debugfs_delif(vif);
#endif /* CONFIG_DEBUG_FS */ #endif /* CONFIG_DEBUG_FS */
xenvif_disconnect_data(be->vif); xenvif_disconnect_data(vif);
for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) for (queue_index = 0;
xenvif_deinit_queue(&be->vif->queues[queue_index]); queue_index < vif->num_queues;
++queue_index)
xenvif_deinit_queue(&vif->queues[queue_index]);
spin_lock(&vif->lock);
queues = vif->queues;
vif->num_queues = 0;
vif->queues = NULL;
spin_unlock(&vif->lock);
spin_lock(&be->vif->lock); vfree(queues);
vfree(be->vif->queues);
be->vif->num_queues = 0;
be->vif->queues = NULL;
spin_unlock(&be->vif->lock);
xenvif_disconnect_ctrl(be->vif); xenvif_disconnect_ctrl(vif);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment