struct net_device *slave)
{
char linkname[IFNAMSIZ+7];
- int ret = 0;
- /* first, create a link from the slave back to the master */
- ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj),
- "master");
- if (ret)
- return ret;
- /* next, create a link from the master to the slave */
+ /* create a link from the master to the slave */
sprintf(linkname, "slave_%s", slave->name);
- ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
- linkname);
-
- /* free the master link created earlier in case of error */
- if (ret)
- sysfs_remove_link(&(slave->dev.kobj), "master");
-
- return ret;
-
+ return sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
+ linkname);
}
void bond_destroy_slave_symlinks(struct net_device *master,
{
char linkname[IFNAMSIZ+7];
- sysfs_remove_link(&(slave->dev.kobj), "master");
sprintf(linkname, "slave_%s", slave->name);
sysfs_remove_link(&(master->dev.kobj), linkname);
}
void *private, bool master)
{
struct netdev_adjacent *adj;
+ int ret;
adj = __netdev_find_adj(dev, adj_dev, dev_list);
adj_dev->name, dev->name, adj_dev->name);
/* Ensure that master link is always the first item in list. */
- if (master)
+ if (master) {
+ ret = sysfs_create_link(&(dev->dev.kobj),
+ &(adj_dev->dev.kobj), "master");
+ if (ret)
+ goto free_adj;
+
list_add_rcu(&adj->list, dev_list);
- else
+ } else {
list_add_tail_rcu(&adj->list, dev_list);
+ }
return 0;
+
+free_adj:
+ kfree(adj);
+
+ return ret;
}
void __netdev_adjacent_dev_remove(struct net_device *dev,
return;
}
+ if (adj->master)
+ sysfs_remove_link(&(dev->dev.kobj), "master");
+
list_del_rcu(&adj->list);
pr_debug("dev_put for %s, because link removed from %s to %s\n",
adj_dev->name, dev->name, adj_dev->name);