From: Stephen Hemminger <shemminger@osdl.org>
To: "David S. Miller" <davem@redhat.com>
Cc: netdev@oss.sgi.com
Subject: [PATCH 2.5.70] sysfs cleanup and bugfix
Date: Thu, 29 May 2003 10:30:11 -0700 [thread overview]
Message-ID: <20030529103011.3f038db7.shemminger@osdl.org> (raw)
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
diff -Nru a/net/core/net-sysfs.c b/net/core/net-sysfs.c
--- a/net/core/net-sysfs.c Thu May 29 10:25:04 2003
+++ b/net/core/net-sysfs.c Thu May 29 10:25:04 2003
@@ -294,7 +294,7 @@
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 @@
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 @@
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);
}
next reply other threads:[~2003-05-29 17:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-29 17:30 Stephen Hemminger [this message]
2003-05-30 3:05 ` [PATCH 2.5.70] sysfs cleanup and bugfix David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030529103011.3f038db7.shemminger@osdl.org \
--to=shemminger@osdl.org \
--cc=davem@redhat.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).