mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] enclosure: fix error path - actually return ERR_PTR() on error
@ 2010-03-12 13:50 Jani Nikula
  2010-03-12 22:14 ` James Bottomley
  0 siblings, 1 reply; 2+ messages in thread
From: Jani Nikula @ 2010-03-12 13:50 UTC (permalink / raw)
  To: linux-kernel, James.Bottomley; +Cc: akpm, ext-jani.1.nikula

Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com>

---

NOTE: I'm afraid I'm unable to test this; please consider this more a
bug report than a complete patch.
---
 drivers/misc/enclosure.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 1eac626..2979927 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -285,7 +285,7 @@ enclosure_component_register(struct enclosure_device *edev,
 
 	err = device_register(cdev);
 	if (err)
-		ERR_PTR(err);
+		return ERR_PTR(err);
 
 	return ecomp;
 }
-- 
1.6.5.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] enclosure: fix error path - actually return ERR_PTR() on error
  2010-03-12 13:50 [PATCH] enclosure: fix error path - actually return ERR_PTR() on error Jani Nikula
@ 2010-03-12 22:14 ` James Bottomley
  0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2010-03-12 22:14 UTC (permalink / raw)
  To: Jani Nikula; +Cc: linux-kernel, akpm, linux-scsi

On Fri, 2010-03-12 at 15:50 +0200, Jani Nikula wrote:
> Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com>
> 
> ---
> 
> NOTE: I'm afraid I'm unable to test this; please consider this more a
> bug report than a complete patch.

It's a good bug report, thanks.  It looks like there's an unreleased
cdev pointer along that path too, so this should be the final fix.

James

---

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 1eac626..68e4cd7 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -284,8 +284,11 @@ enclosure_component_register(struct enclosure_device *edev,
 	cdev->groups = enclosure_groups;
 
 	err = device_register(cdev);
-	if (err)
-		ERR_PTR(err);
+	if (err) {
+		ecomp->number = -1;
+		put_device(cdev);
+		return ERR_PTR(err);
+	}
 
 	return ecomp;
 }




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-12 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-12 13:50 [PATCH] enclosure: fix error path - actually return ERR_PTR() on error Jani Nikula
2010-03-12 22:14 ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®