public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firewire: fix "kobject_add failed for fw* with -EEXIST"
@ 2008-01-27  0:05 Stefan Richter
  2008-01-27 17:20 ` [PATCH update] " Stefan Richter
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Richter @ 2008-01-27  0:05 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Jarod Wilson, Kristian Høgsberg, linux-kernel

There is a race between shutdown and creation of devices:  fw-core may
attempt to add a device with the same name of an already existing
device.  http://bugzilla.kernel.org/show_bug.cgi?id=9828

Impact of the bug:  Happens rarely, forces the user to unplug and replug
the new device to get it working.

The fix is to defer the deregistration of the minor number until after
device_unregister().  This requires an adjustment of the device lookup
function though to prevent the character device from being newly opened
during shutdown.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
 drivers/firewire/fw-device.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Index: linux/drivers/firewire/fw-device.c
===================================================================
--- linux.orig/drivers/firewire/fw-device.c
+++ linux/drivers/firewire/fw-device.c
@@ -616,6 +616,8 @@ struct fw_device *fw_device_from_devt(de
 
 	down_read(&idr_rwsem);
 	device = idr_find(&fw_device_idr, MINOR(devt));
+	if (fw_device_is_shutdown(device))
+		device = NULL;
 	up_read(&idr_rwsem);
 
 	return device;
@@ -627,13 +629,13 @@ static void fw_device_shutdown(struct wo
 		container_of(work, struct fw_device, work.work);
 	int minor = MINOR(device->device.devt);
 
-	down_write(&idr_rwsem);
-	idr_remove(&fw_device_idr, minor);
-	up_write(&idr_rwsem);
-
 	fw_device_cdev_remove(device);
 	device_for_each_child(&device->device, NULL, shutdown_unit);
+
+	down_write(&idr_rwsem);
 	device_unregister(&device->device);
+	idr_remove(&fw_device_idr, minor);
+	up_write(&idr_rwsem);
 }
 
 static struct device_type fw_device_type = {

-- 
Stefan Richter
-=====-==--- ---= ==-==
http://arcgraph.de/sr/


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

end of thread, other threads:[~2008-02-02 14:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-27  0:05 [PATCH] firewire: fix "kobject_add failed for fw* with -EEXIST" Stefan Richter
2008-01-27 17:20 ` [PATCH update] " Stefan Richter
2008-01-27 17:21   ` [PATCH] firewire: fail open() quickly if the node doesn't exist anymore Stefan Richter
2008-01-28 22:32     ` Jarod Wilson
2008-01-28 23:50       ` Stefan Richter
2008-01-28 16:48   ` [PATCH update] firewire: fix "kobject_add failed for fw* with -EEXIST" Jarod Wilson
2008-01-28 18:54     ` Stefan Richter
2008-01-28 22:24       ` Jarod Wilson
2008-01-28 19:16     ` Stefan Richter
2008-01-28 23:31       ` Stefan Richter
2008-02-02 14:01         ` [PATCH update 2] " Stefan Richter
2008-01-28 22:30   ` [PATCH update] " Jarod Wilson

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