On 06/15/2015 10:56 AM, Matt Ranostay wrote:
> On Mon, Jun 15, 2015 at 1:15 AM, Jacek Anaszewski
> <[email protected]> wrote:

>>> +               error = devm_led_classdev_register(dev, &led->cdev);
>>> +               if (error < 0)
>>> +                       return -EINVAL;
>>> +               INIT_WORK(&led->work, cap11xx_led_work);
>>> +               schedule_work(&led->work);
>>
>>
>> Work queue should be initialized before registration of the LED class
>> device.
> What is the reason for this? Just curious

It's a race condition. The LED device is accessible once
devm_led_classdev_register() returns. So a user could be calling into
cap11xx_led_set() before the work queue is initialized, which would
hence access a NULL pointer.


Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to