summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2003-05-29 06:04:32 -0700
committerDavid S. Miller <davem@nuts.ninka.net>2003-05-29 06:04:32 -0700
commit8448d20fc7140f5d747df779ffc52cc952147de7 (patch)
treec8a3a5d37f5ae2979b3b4e76a42a4a140d744389 /net/core
parent51d9af05725442c96d6b86fd39c6a6716a39f637 (diff)
[NET]: Sysfs netdev cleanup and bugfix.
A couple of bugs in netdev_unregister_sysfs; still working on the harder refcount issues. - if driver sets get_stats after register then unregister will attempt to delete kobject that has not be initialized. - unregister should call kobject_unregister not kobject_del. cleanup's: - use strlcpy instead of snprintf - don't need to memset the stats kobject
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-sysfs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index e0da193e98fb..a0115f504b09 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -294,7 +294,7 @@ int netdev_register_sysfs(struct net_device *net)
class_dev->class = &net_class;
class_dev->class_data = net;
- snprintf(class_dev->class_id, BUS_ID_SIZE, net->name);
+ strlcpy(class_dev->class_id, net->name, BUS_ID_SIZE);
if ((ret = class_device_register(class_dev)))
goto out;
@@ -303,17 +303,18 @@ int netdev_register_sysfs(struct net_device *net)
goto out_unreg;
}
+
+ net->stats_kobj.parent = NULL;
if (net->get_stats) {
struct kobject *k = &net->stats_kobj;
- memset(k, 0, sizeof(*k));
k->parent = kobject_get(&class_dev->kobj);
if (!k->parent) {
ret = -EBUSY;
goto out_unreg;
}
- snprintf(k->name, KOBJ_NAME_LEN, "%s", "statistics");
+ strlcpy(k->name, "statistics", KOBJ_NAME_LEN);
k->ktype = &netstat_ktype;
if((ret = kobject_register(k)))
@@ -331,8 +332,9 @@ out_unreg:
void netdev_unregister_sysfs(struct net_device *net)
{
- if (net->get_stats)
- kobject_del(&net->stats_kobj);
+ if (net->stats_kobj.parent)
+ kobject_unregister(&net->stats_kobj);
+
class_device_unregister(&net->class_dev);
}