@@ -5158,6 +5158,7 @@ static void rollback_registered_many(struct list_head *head)
/* Remove entries from kobject tree */
netdev_unregister_kobject(dev);
+ netdev_del_kobject(dev);
}
/* Process any work delayed until the end of the batch */
@@ -5432,7 +5433,6 @@ int register_netdevice(struct net_device *dev)
ret = netdev_register_kobject(dev);
if (ret)
goto err_uninit;
- dev->reg_state = NETREG_REGISTERED;
netdev_update_features(dev);
@@ -5447,6 +5447,12 @@ int register_netdevice(struct net_device *dev)
dev_hold(dev);
list_netdevice(dev);
+ ret = netdev_add_kobject(dev);
+ if (ret)
+ goto err_unregister;
+
+ dev->reg_state = NETREG_REGISTERED;
+
/* Notify protocols, that a new device appeared. */
ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
ret = notifier_to_errno(ret);
@@ -5465,6 +5471,9 @@ int register_netdevice(struct net_device *dev)
out:
return ret;
+err_unregister:
+ netdev_unregister_kobject(dev);
+
err_uninit:
if (dev->netdev_ops->ndo_uninit)
dev->netdev_ops->ndo_uninit(dev);
@@ -1303,8 +1303,6 @@ void netdev_unregister_kobject(struct net_device * net)
kobject_get(&dev->kobj);
remove_queue_kobjects(net);
-
- device_del(dev);
}
/* Create sysfs entries for network device. */
@@ -1312,7 +1310,6 @@ int netdev_register_kobject(struct net_device *net)
{
struct device *dev = &(net->dev);
const struct attribute_group **groups = net->sysfs_groups;
- int error = 0;
device_initialize(dev);
dev->class = &net_class;
@@ -1337,17 +1334,21 @@ int netdev_register_kobject(struct net_device *net)
#endif
#endif /* CONFIG_SYSFS */
- error = device_add(dev);
- if (error)
- return error;
+ return register_queue_kobjects(net);
+}
- error = register_queue_kobjects(net);
- if (error) {
- device_del(dev);
- return error;
- }
+void netdev_del_kobject(struct net_device *net)
+{
+ struct device *dev = &(net->dev);
- return error;
+ device_del(dev);
+}
+
+int netdev_add_kobject(struct net_device *net)
+{
+ struct device *dev = &(net->dev);
+
+ return device_add(dev);
}
int netdev_class_create_file(struct class_attribute *class_attr)
@@ -4,6 +4,8 @@
int netdev_kobject_init(void);
int netdev_register_kobject(struct net_device *);
void netdev_unregister_kobject(struct net_device *);
+int netdev_add_kobject(struct net_device *net);
+void netdev_del_kobject(struct net_device *net);
int net_rx_queue_update_kobjects(struct net_device *, int old_num, int new_num);
int netdev_queue_update_kobjects(struct net_device *net,
int old_num, int new_num);