linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bsg: fix bsg_register_queue error path
@ 2007-07-20 21:50 James Bottomley
  2007-07-21  1:14 ` FUJITA Tomonori
  0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2007-07-20 21:50 UTC (permalink / raw)
  To: FUJITA Tomonori, Jens Axboe; +Cc: linux-scsi

unfortunately, if IS_ERR(class_dev) is true, that means class_dev isn't
null and the check in the error leg is pointless ... it's also asking
for trouble to request unregistration of a device we haven't actually
created (although it works currently).  Fix by using explicit gotos and
unregisters.

James

diff --git a/block/bsg.c b/block/bsg.c
index d4fa8cd..1659d63 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -993,7 +993,7 @@ retry:
 	if (q->kobj.sd) {
 		ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg");
 		if (ret)
-			goto err;
+			goto err_unregister;
 	}
 
 	list_add_tail(&bcd->list, &bsg_class_list);
@@ -1001,9 +1001,10 @@ retry:
 
 	mutex_unlock(&bsg_mutex);
 	return 0;
+
+err_unregister:
+	class_device_unregister(class_dev);
 err:
-	if (class_dev)
-		class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor));
 	mutex_unlock(&bsg_mutex);
 	return ret;
 }



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

* Re: [PATCH] bsg: fix bsg_register_queue error path
  2007-07-20 21:50 [PATCH] bsg: fix bsg_register_queue error path James Bottomley
@ 2007-07-21  1:14 ` FUJITA Tomonori
  0 siblings, 0 replies; 2+ messages in thread
From: FUJITA Tomonori @ 2007-07-21  1:14 UTC (permalink / raw)
  To: James.Bottomley; +Cc: fujita.tomonori, Jens.Axboe, linux-scsi

From: James Bottomley <James.Bottomley@SteelEye.com>
Subject: [PATCH] bsg: fix bsg_register_queue error path
Date: Fri, 20 Jul 2007 16:50:10 -0500

> unfortunately, if IS_ERR(class_dev) is true, that means class_dev isn't
> null and the check in the error leg is pointless ... it's also asking
> for trouble to request unregistration of a device we haven't actually
> created (although it works currently).  Fix by using explicit gotos and
> unregisters.

ACK, thanks.

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

end of thread, other threads:[~2007-07-21  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-20 21:50 [PATCH] bsg: fix bsg_register_queue error path James Bottomley
2007-07-21  1:14 ` FUJITA Tomonori

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).