• Petr Machata's avatar
    vxlan: Fix error path in __vxlan_dev_create() · 6db92468
    Petr Machata authored
    When a failure occurs in rtnl_configure_link(), the current code
    calls unregister_netdevice() to roll back the earlier call to
    register_netdevice(), and jumps to errout, which calls
    vxlan_fdb_destroy().
    
    However unregister_netdevice() calls transitively ndo_uninit, which is
    vxlan_uninit(), and that already takes care of deleting the default FDB
    entry by calling vxlan_fdb_delete_default(). Since the entry added
    earlier in __vxlan_dev_create() is exactly the default entry, the
    cleanup code in the errout block always leads to double free and thus a
    panic.
    
    Besides, since vxlan_fdb_delete_default() always destroys the FDB entry
    with notification enabled, the deletion of the default entry is notified
    even before the addition was notified.
    
    Instead, move the unregister_netdevice() call after the manual destroy,
    which solves both problems.
    
    Fixes: 0241b836 ("vxlan: fix default fdb entry netlink notify ordering during netdev create")
    Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6db92468
vxlan.c 100 KB