[ovs-dev] [PATCH 2/2] veth: Do a better job cleaning up on rmmod

Jesse Gross jesse at nicira.com
Wed Apr 21 14:46:18 UTC 2010


On Wed, Apr 21, 2010 at 1:50 AM, Justin Pettit <jpettit at nicira.com> wrote:
>
>  static __exit void veth_exit(void)
>  {
> +       struct veth_priv *p, *n;
> +
> +       rtnl_lock();
> +       list_for_each_entry_safe(p, n, &veth_list, list) {
> +               veth_dellink(p->dev);
> +       }
>

I don't think this is safe.  With the *_safe variants of functions it is OK
to remove the current element but not necessarily arbitrary elements since
they store the next list entry in n before returning p so you can delete p.
 However, veth_dellink deletes both the link and its peer (which is probably
the next entry).

Also, kernel style is to drop the braces.


> +       rtnl_unlock();
> +
>        unregister_netdevice_notifier(&veth_notifier_block);
> +       veth_destroy_sysfs();
>  }
>
>  module_init(veth_init);
>

Otherwise good catches.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20100421/0bab3c8a/attachment-0003.html>


More information about the dev mailing list