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();