Skip to content

Commit

Permalink
leds: trigger: Fix error path to not unlock the unlocked mutex
Browse files Browse the repository at this point in the history
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: fd4a641 ("leds: trigger: implement a tty trigger")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
  • Loading branch information
ukleinek authored and intel-lab-lkp committed Feb 19, 2021
1 parent a157270 commit f13a575
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/leds/trigger/ledtrig-tty.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit f13a575

Please sign in to comment.