From: Maneesh Soni <maneesh@in.ibm.com>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: linux-kernel@vger.kernel.org,
viro@parcelfarce.linux.theplanet.co.uk, Greg KH <greg@kroah.com>,
Jeff Garzik <jgarzik@pobox.com>
Subject: Re: [RFC 1/2] kobject_set_name - error handling
Date: Tue, 4 May 2004 11:09:08 +0530 [thread overview]
Message-ID: <20040504053908.GA2900@in.ibm.com> (raw)
In-Reply-To: <200404300748.14151.dtor_core@ameritech.net>
On Fri, Apr 30, 2004 at 07:48:13AM -0500, Dmitry Torokhov wrote:
> On Friday 30 April 2004 05:14 am, Maneesh Soni wrote:
>
> > diff -puN drivers/base/bus.c~kobject_set_name-cleanup-01 drivers/base/bus.c
> > --- linux-2.6.6-rc2-mm2/drivers/base/bus.c~kobject_set_name-cleanup-01 2004-04-30 15:14:03.000000000 +0530
> > +++ linux-2.6.6-rc2-mm2-maneesh/drivers/base/bus.c 2004-04-30 15:14:03.000000000 +0530
> > @@ -451,7 +451,9 @@ int bus_add_driver(struct device_driver
> >
> > if (bus) {
> > pr_debug("bus %s: add driver %s\n",bus->name,drv->name);
> > - kobject_set_name(&drv->kobj,drv->name);
> > + error = kobject_set_name(&drv->kobj,drv->name);
> > + if (error)
> > + return error;
>
> Hi, I think you are leaking a reference here, put_bus() is needed.
>
> > drv->kobj.kset = &bus->drivers;
> > if ((error = kobject_register(&drv->kobj))) {
> > put_bus(bus);
>
Thanks for spotting it. Corrected patch is appended.
Greg, Are the patches fit for inclusion? I need to know this as my sysfs backing
store patches are taking back seats because of these changes, particulary the
one in second patch :-(.
Thanks
Maneesh
o The following patch cleans up the kobject_set_name() users. Basically checking
return code from kobject_set_name(). There can be error returns like -ENOMEM
or -EFAULT from kobject_set_name() if the name length exceeds KOBJ_NAME_LEN.
drivers/base/bus.c | 14 +++++++++++---
drivers/base/sys.c | 5 ++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff -puN drivers/base/sys.c~kobject_set_name-cleanup-01 drivers/base/sys.c
--- linux-2.6.6-rc3-mm1/drivers/base/sys.c~kobject_set_name-cleanup-01 2004-04-30 16:07:32.000000000 +0530
+++ linux-2.6.6-rc3-mm1-maneesh/drivers/base/sys.c 2004-04-30 16:07:32.000000000 +0530
@@ -180,8 +180,11 @@ int sysdev_register(struct sys_device *
/* But make sure we point to the right type for sysfs translation */
sysdev->kobj.ktype = &ktype_sysdev;
- kobject_set_name(&sysdev->kobj,"%s%d",
+ error = kobject_set_name(&sysdev->kobj,"%s%d",
kobject_name(&cls->kset.kobj),sysdev->id);
+ if (error)
+ return error;
+
pr_debug("Registering sys device '%s'\n",kobject_name(&sysdev->kobj));
/* Register the object */
diff -puN drivers/base/bus.c~kobject_set_name-cleanup-01 drivers/base/bus.c
--- linux-2.6.6-rc3-mm1/drivers/base/bus.c~kobject_set_name-cleanup-01 2004-04-30 16:07:32.000000000 +0530
+++ linux-2.6.6-rc3-mm1-maneesh/drivers/base/bus.c 2004-05-04 11:01:52.000000000 +0530
@@ -451,7 +451,11 @@ int bus_add_driver(struct device_driver
if (bus) {
pr_debug("bus %s: add driver %s\n",bus->name,drv->name);
- kobject_set_name(&drv->kobj,drv->name);
+ error = kobject_set_name(&drv->kobj,drv->name);
+ if (error) {
+ put_bus(bus)
+ return error;
+ }
drv->kobj.kset = &bus->drivers;
if ((error = kobject_register(&drv->kobj))) {
put_bus(bus);
@@ -555,7 +559,11 @@ struct bus_type * find_bus(char * name)
*/
int bus_register(struct bus_type * bus)
{
- kobject_set_name(&bus->subsys.kset.kobj,bus->name);
+ int error = 0;
+
+ error = kobject_set_name(&bus->subsys.kset.kobj,bus->name);
+ if (error)
+ return error;
subsys_set_kset(bus,bus_subsys);
subsystem_register(&bus->subsys);
@@ -569,7 +577,7 @@ int bus_register(struct bus_type * bus)
kset_register(&bus->drivers);
pr_debug("bus type '%s' registered\n",bus->name);
- return 0;
+ return error;
}
_
--
Maneesh Soni
Linux Technology Center,
IBM Software Lab, Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-25044999 Fax: 91-80-25268553
T/L : 9243696
next prev parent reply other threads:[~2004-05-04 5:35 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-13 12:40 [RFC] fix sysfs symlinks Maneesh Soni
2004-04-13 13:36 ` viro
2004-04-14 6:40 ` Maneesh Soni
2004-04-14 7:02 ` viro
2004-04-14 7:17 ` Maneesh Soni
2004-04-14 7:27 ` viro
2004-04-15 8:17 ` Russell King
2004-04-15 10:38 ` viro
2004-04-15 15:19 ` Russell King
2004-04-15 16:10 ` Greg KH
2004-04-15 16:13 ` viro
2004-04-15 19:14 ` viro
2004-04-15 21:27 ` Greg KH
2004-04-17 6:15 ` Rusty Russell
2004-04-17 19:39 ` viro
2004-04-17 23:45 ` Rusty Russell
2004-04-15 22:02 ` Greg KH
2004-04-16 15:24 ` viro
2004-04-16 18:03 ` Horst von Brand
2004-04-16 18:07 ` viro
2004-04-16 22:37 ` Greg KH
2004-04-16 23:46 ` viro
2004-04-17 0:03 ` Jeff Garzik
2004-04-17 8:07 ` Russell King
2004-04-17 8:22 ` viro
2004-04-20 16:16 ` Greg KH
2004-04-21 10:11 ` Maneesh Soni
2004-04-22 21:37 ` viro
2004-04-23 8:52 ` Maneesh Soni
2004-04-23 9:26 ` viro
2004-04-29 13:03 ` Maneesh Soni
2004-04-29 15:41 ` viro
2004-04-30 10:05 ` Maneesh Soni
2004-04-30 10:13 ` [RFC 0/2] kobject_set_name - error handling Maneesh Soni
2004-04-30 10:14 ` [RFC 1/2] " Maneesh Soni
2004-04-30 10:17 ` [RFC 2/2] " Maneesh Soni
2004-05-04 13:08 ` Maneesh Soni
2004-04-30 12:48 ` [RFC 1/2] " Dmitry Torokhov
2004-05-04 5:39 ` Maneesh Soni [this message]
2004-05-04 9:19 ` Maneesh Soni
2004-05-07 22:25 ` Greg KH
2003-05-09 10:05 ` Maneesh Soni
2003-05-09 10:09 ` [RFC 2/2] sysfs_rename_dir-cleanup Maneesh Soni
2004-05-11 23:33 ` Greg KH
2004-10-07 5:16 ` Maneesh Soni
2004-10-07 5:38 ` Maneesh Soni
2004-05-14 19:10 ` Greg KH
2004-05-11 23:32 ` [RFC 1/2] kobject_set_name - error handling Greg KH
2004-04-17 0:15 ` [RFC] fix sysfs symlinks Greg KH
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=20040504053908.GA2900@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=dtor_core@ameritech.net \
--cc=greg@kroah.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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