mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
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: fd4a641ac8
("leds: trigger: implement a tty trigger")
Reported-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210219133307.4840-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a38fd87484
commit
1487e7bae8
@@ -51,10 +51,8 @@ static ssize_t ttyname_store(struct device *dev,
|
|||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
|
ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
|
||||||
if (!ttyname) {
|
if (!ttyname)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out_unlock;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ttyname = NULL;
|
ttyname = NULL;
|
||||||
}
|
}
|
||||||
@@ -69,7 +67,6 @@ static ssize_t ttyname_store(struct device *dev,
|
|||||||
|
|
||||||
trigger_data->ttyname = ttyname;
|
trigger_data->ttyname = ttyname;
|
||||||
|
|
||||||
out_unlock:
|
|
||||||
mutex_unlock(&trigger_data->mutex);
|
mutex_unlock(&trigger_data->mutex);
|
||||||
|
|
||||||
if (ttyname && !running)
|
if (ttyname && !running)
|
||||||
|
Reference in New Issue
Block a user