LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 7/8] Driver core: Fix cleanup when failing device_add().
Date: Tue,  4 Mar 2008 15:18:51 -0800	[thread overview]
Message-ID: <1204672732-3127-7-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080304231519.GC3073@suse.de>

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Driver core: Fix cleanup when failing device_add().

 - Don't call cleanup_device_parent() if we didn't call setup_parent().
 - dev->kobj.parent may be NULL when cleanup_device_parent() is called,
   so we need to handle glue_dir == NULL in cleanup_glue_dir().

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/core.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7f59c2f..7de543d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -621,7 +621,8 @@ static struct kobject *get_device_parent(struct device *dev,
 static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
 {
 	/* see if we live in a "glue" directory */
-	if (!dev->class || glue_dir->kset != &dev->class->class_dirs)
+	if (!glue_dir || !dev->class ||
+	    glue_dir->kset != &dev->class->class_dirs)
 		return;
 
 	kobject_put(glue_dir);
@@ -773,7 +774,7 @@ int device_add(struct device *dev)
 	dev = get_device(dev);
 	if (!dev || !strlen(dev->bus_id)) {
 		error = -EINVAL;
-		goto Error;
+		goto Done;
 	}
 
 	pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
-- 
1.5.4.3


  parent reply	other threads:[~2008-03-04 23:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 23:15 [GIT PATCH] driver core fixes against 2.6.25-rc3 git Greg KH
2008-03-04 23:18 ` [PATCH 1/8] driver core: fix up Kconfig text for CONFIG_SYSFS_DEPRECATED Greg Kroah-Hartman
2008-03-05 15:58   ` Valdis.Kletnieks
2008-03-05 16:05     ` Greg KH
2008-03-05 21:24       ` Valdis.Kletnieks
2008-03-04 23:18 ` [PATCH 2/8] sysfs: CONFIG_SYSFS_DEPRECATED fix Greg Kroah-Hartman
2008-03-04 23:18 ` [PATCH 3/8] kobject: properly initialize ksets Greg Kroah-Hartman
2008-03-04 23:18 ` [PATCH 4/8] PM: Do not acquire device semaphores upfront during suspend Greg Kroah-Hartman
2008-03-04 23:18 ` [PATCH 5/8] PM: fix new mutex-locking bug in the PM core Greg Kroah-Hartman
2008-03-04 23:18 ` [PATCH 6/8] driver core: Remove dpm_sysfs_remove() from error path of device_add() Greg Kroah-Hartman
2008-03-04 23:18 ` Greg Kroah-Hartman [this message]
2008-03-04 23:18 ` [PATCH 8/8] debugfs: fix sparse warnings Greg Kroah-Hartman

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=1204672732-3127-7-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=cornelia.huck@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 7/8] Driver core: Fix cleanup when failing device_add().' \
    /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).