[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210219082955.5007-1-u.kleine-koenig@pengutronix.de>
Date: Fri, 19 Feb 2021 09:29:54 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: Pavel Machek <pavel@....cz>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
linux-leds@...r.kernel.org, kernel@...gutronix.de
Subject: [PATCH 1/2] 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.
Reported-by: Pavel Machek <pavel@....cz>
Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
---
drivers/leds/trigger/ledtrig-tty.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
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;
}
--
2.29.2
Powered by blists - more mailing lists