Skip to contentSkip to conversation

Fix panic in virtnet_remove

PATCH In review Krishna Kumar 3 participants 4 messages Jul 15, 2011 – Jul 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix panic in virtnet_remove

modprobe -r virtio_net panics in free_netdev() as the dev is already freed in the newly introduced virtnet_free (commit 3fa2a1df9094). Since virtnet_remove doesn't require dev after unregister, I am removing the free_netdev call in virtnet_remove instead of in virtnet_free (which seems to be the right place to free the dev). Confirmed that the panic is fixed with this patch.

---
 drivers/net/virtio_net.c |    2 --
 1 file changed, 2 deletions(-)
drivers/net/virtio_net.c +0 -2
diff -ruNp org/drivers/net/virtio_net.c new/drivers/net/virtio_net.c
@@ -1121,8 +1121,6 @@ static void __devexit virtnet_remove(str
 
 	while (vi->pages)
 		__free_pages(get_a_page(vi, GFP_KERNEL), 0);
-
-	free_netdev(vi->dev);
 }
 
 static struct virtio_device_id id_table[] = {
maintainer
#1 lore raw

From: Krishna Kumar <[email protected]>
Date: Fri, 15 Jul 2011 14:46:50 +0530

Quoted 9 lines

modprobe -r virtio_net panics in free_netdev() as the dev is already freed in the newly introduced virtnet_free (commit 3fa2a1df9094). Since virtnet_remove doesn't require dev after unregister, I am removing the free_netdev call in virtnet_remove instead of in virtnet_free (which seems to be the right place to free the dev). Confirmed that the panic is fixed with this patch.

I guess the virtio NET maintainers don't deserve to get CC:'d on a fix like this? :-(

Michael Tsirkin is who maintains this driver actively and is the one who will merge this kind of fix to me, therefore if you don't CC:
him it might not get integrated at all.

#2 lore raw

David Miller <[email protected]> wrote on 07/15/2011 08:49:09 PM:

Quoted 8 lines
Quoted 8 lines

modprobe -r virtio_net panics in free_netdev() as the dev is already freed in the newly introduced virtnet_free (commit 3fa2a1df9094). Since virtnet_remove doesn't require dev after unregister, I am removing the free_netdev call in virtnet_remove instead of in virtnet_free (which seems to be the right place to free the dev). Confirmed that the panic is fixed with this patch.

Quoted 8 lines
Quoted 1 line

I guess the virtio NET maintainers don't deserve to get CC:'d on a fix like this? :-(

Michael Tsirkin is who maintains this driver actively and is the one who will merge this kind of fix to me, therefore if you don't CC:
him it might not get integrated at all.

Sorry, but it was not intentional. I saw that Stephen had made that change so cc'd him instead.

Michael, I am attaching the patch below, please let me know if you need it inlined:

(See attached file: patch)

Thanks,

- KK

#3 lore raw
In reply to Krishna Kumar
Quoted 3 lines · Krishna Kumar

modprobe -r virtio_net panics in free_netdev() as the dev is already freed in the newly introduced virtnet_free (commit 3fa2a1df9094).

Good catch, thanks!

Quoted 2 lines

Since virtnet_remove doesn't require
dev after unregister,

I'm not sure that true: vi used just above the line you remove is I think the struct virtnet_info that is allocated as part of that structure.

Quoted 4 lines

I am removing the free_netdev call
in virtnet_remove instead of in virtnet_free (which seems to be the right place to free the dev). Confirmed that the panic is fixed with this patch.

This might be just because the memory isn't reused.
Try enabling slab poisoning, I think you'll observe some problems.

Do we absolutely have to have a destructor?
Can't we move the per cpu counter free from
virtnet_free to virtnet_remove, and get rid of
virtnet_free completely?

Quoted 21 lines
---
 drivers/net/virtio_net.c |    2 --
 1 file changed, 2 deletions(-)

diff -ruNp org/drivers/net/virtio_net.c new/drivers/net/virtio_net.c

drivers/net/virtio_net.c +0 -3
@@ -1121,8 +1121,6 @@ static void __devexit virtnet_remove(str
 
 	while (vi->pages)
 		__free_pages(get_a_page(vi, GFP_KERNEL), 0);
-
-	free_netdev(vi->dev);
 }
 
 static struct virtio_device_id id_table[] = {
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html