Message ID | 20210219082955.5007-1-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers | show |
Series | [1/2] leds: trigger: Fix error path to not unlock the unlocked mutex | expand |
On Fri 2021-02-19 09:29:54, Uwe Kleine-König wrote: > ttyname is allocated before the mutex is taken, so it must not be > unlocked in the error path. > Acked-by: Pavel Machek <pavel@ucw.cz>
On Fri, Feb 19, 2021 at 10:46:32AM +0100, Pavel Machek wrote: > On Fri 2021-02-19 09:29:55, Uwe Kleine-König wrote: > > led_set_brightness() involves scheduling a workqueue. As here the led's > > brightness setting is done in context of the trigger's workqueue this is > > unjustified overhead and it's more sensible to use > > led_set_brightness_sync(). > > Acked-by: Pavel Machek <pavel@ucw.cz> Who is expected to pick these two up? I assume Greg as the commit that is fixed here is only in his try for now? Best regards Uwe
diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c index d2ab6ab080ac..68ed2c87a65c 100644 --- a/drivers/leds/trigger/ledtrig-tty.c +++ b/drivers/leds/trigger/ledtrig-tty.c @@ -51,10 +51,8 @@ static ssize_t ttyname_store(struct device *dev, if (size) { ttyname = kmemdup_nul(buf, size, GFP_KERNEL); - if (!ttyname) { - ret = -ENOMEM; - goto out_unlock; - } + if (!ttyname) + return -ENOMEM; } else { ttyname = NULL; }
ttyname is allocated before the mutex is taken, so it must not be unlocked in the error path. Reported-by: Pavel Machek <pavel@ucw.cz> Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/leds/trigger/ledtrig-tty.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)