From: Francesco Ruggeri Date: Sat, 23 Apr 2016 22:04:31 +0000 (-0700) Subject: macvtap: check minor when unregistering X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e96c37f185529d1db4ebc021e4f56822d43945bb;p=linux-beck.git macvtap: check minor when unregistering macvtap_device_event(NETDEV_UNREGISTER) should check vlan->minor to determine if it is being invoked in the context of a macvtap_newlink that failed, for example in this code sequence: macvtap_newlink macvlan_common_newlink register_netdevice call_netdevice_notifiers(NETDEV_REGISTER, dev) macvtap_device_event(NETDEV_REGISTER) minor = 0> rollback_registered(dev); rollback_registered_many call_netdevice_notifiers(NETDEV_UNREGISTER, dev); macvtap_device_event(NETDEV_UNREGISTER) Signed-off-by: Francesco Ruggeri Acked-by: "Eric W. Biederman" Signed-off-by: David S. Miller --- diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 95394edd1ed5..74cb15a2e032 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -1303,6 +1303,9 @@ static int macvtap_device_event(struct notifier_block *unused, } break; case NETDEV_UNREGISTER: + /* vlan->minor == 0 if NETDEV_REGISTER above failed */ + if (vlan->minor == 0) + break; devt = MKDEV(MAJOR(macvtap_major), vlan->minor); device_destroy(macvtap_class, devt); macvtap_free_minor(vlan);