brcompat refactoring fixes
authorBen Pfaff <blp@nicira.com>
Thu, 21 May 2009 18:10:19 +0000 (11:10 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 21 May 2009 18:10:19 +0000 (11:10 -0700)
datapath/brcompat.c

index 3958459022f2e4a6a72b6b72b7579d77ea085f89..4175ad1cc1cf898ca53cdae5bb98e34e83d03359 100644 (file)
@@ -146,14 +146,20 @@ static int
 brc_add_del_port(struct net_device *dev, int port_ifindex, int add)
 {
        struct net_device *port;
+       char dev_name[IFNAMSIZ], port_name[IFNAMSIZ];
        int err;
 
        port = __dev_get_by_index(&init_net, port_ifindex);
        if (!port)
                return -EINVAL;
 
+       /* Save name of dev and port because there's a race between the
+        * rtnl_unlock() and the brc_send_command(). */
+       strcpy(dev_name, dev->name);
+       strcpy(port_name, port->name);
+
        rtnl_unlock();
-       err = brc_send_command(dev->name, port->name,
+       err = brc_send_command(dev_name, port_name,
                               add ? BRC_GENL_C_PORT_ADD : BRC_GENL_C_PORT_DEL);
        rtnl_lock();