LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Greg KH <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: [Patch] Driver core: Fix error handling in bus_add_driver().
Date: Mon, 18 Feb 2008 17:04:25 +0100 [thread overview]
Message-ID: <20080218170425.56d03e37@gondolin.boeblingen.de.ibm.com> (raw)
- If the allocation of ->priv fails, the reference on the bus
must be dropped.
- If adding the kobject fails, kobject_put must be called to
clean things up.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/base/bus.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
--- linux-2.6.orig/drivers/base/bus.c
+++ linux-2.6/drivers/base/bus.c
@@ -658,9 +658,10 @@ int bus_add_driver(struct device_driver
pr_debug("bus: '%s': add driver %s\n", bus->name, drv->name);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
+ if (!priv) {
+ error = -ENOMEM;
+ goto out_put_bus;
+ }
klist_init(&priv->klist_devices, NULL, NULL);
priv->driver = drv;
drv->p = priv;
@@ -668,7 +669,7 @@ int bus_add_driver(struct device_driver
error = kobject_init_and_add(&priv->kobj, &driver_ktype, NULL,
"%s", drv->name);
if (error)
- goto out_put_bus;
+ goto out_unregister;
if (drv->bus->p->drivers_autoprobe) {
error = driver_attach(drv);
reply other threads:[~2008-02-18 16:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080218170425.56d03e37@gondolin.boeblingen.de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [Patch] Driver core: Fix error handling in bus_add_driver().' \
/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
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).