Commit 1487e7ba authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman

leds: trigger: Fix error path to not unlock the unlocked mutex

ttyname is allocated before the mutex is taken, so it must not be
unlocked in the error path.

Fixes: fd4a641a ("leds: trigger: implement a tty trigger")
Reported-by: default avatarPavel Machek <pavel@ucw.cz>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210219133307.4840-2-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a38fd874
......@@ -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;
}
......@@ -69,7 +67,6 @@ static ssize_t ttyname_store(struct device *dev,
trigger_data->ttyname = ttyname;
out_unlock:
mutex_unlock(&trigger_data->mutex);
if (ttyname && !running)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment