Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] macvtap: check minor when unregistering
@ 2016-04-23 22:04 Francesco Ruggeri
  2016-04-25 19:01 ` Eric W. Biederman
  2016-04-26 19:19 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Francesco Ruggeri @ 2016-04-23 22:04 UTC (permalink / raw)
  To: netdev; +Cc: Francesco Ruggeri, Eric W. Biederman, David S. Miller

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)
          <fail here, vlan->minor = 0>
      rollback_registered(dev);
        rollback_registered_many
          call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
            macvtap_device_event(NETDEV_UNREGISTER)
              <nothing to clean up here>

Signed-off-by: Francesco Ruggeri <fruggeri@arista.com>
---
 drivers/net/macvtap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 95394ed..74cb15a 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);
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-26 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-23 22:04 [PATCH net-next] macvtap: check minor when unregistering Francesco Ruggeri
2016-04-25 19:01 ` Eric W. Biederman
2016-04-26 19:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox