Re: [RESEND][RFC][PATCH] leds: fix oops race in led trigger registration

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Richard Purdie
Date: Thursday, August 21, 2008 - 1:06 am

Hi,

On Thu, 2008-08-21 at 09:17 +0200, Vegard Nossum wrote:

This patch isn't quite right since whilst it fixes one race, it opens up
a number of other potential problems. We definitely should have the led
listed in leds_list before calling the various functions and the
existing init order is correct in that sense.

I suspect your problem is caused by something calling a trigger
registration between the point its added to the list and the
init_rwsem(). The best solution is to move the init_rwsem() to earlier
in the function. Yes, that means some ifdef ugliness but so be it. Could
you see whether you still see the problem with the patch below?

Cheers,

Richard


diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 559a408..c9d8219 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -113,6 +113,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
 	if (rc)
 		goto err_out;
 
+#ifdef CONFIG_LEDS_TRIGGERS
+	init_rwsem(&led_cdev->trigger_lock);
+#endif
 	/* add to the list of leds */
 	down_write(&leds_list_lock);
 	list_add_tail(&led_cdev->node, &leds_list);
@@ -121,8 +124,6 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
 	led_update_brightness(led_cdev);
 
 #ifdef CONFIG_LEDS_TRIGGERS
-	init_rwsem(&led_cdev->trigger_lock);
-
 	rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
 	if (rc)
 		goto err_out_led_list;





--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RESEND][RFC][PATCH] leds: fix oops race in led trigge ..., Richard Purdie, (Thu Aug 21, 1:06 am)