All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex
@ 2021-02-19  8:29 Uwe Kleine-König
  2021-02-19  8:29 ` [PATCH 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2021-02-19  8:29 UTC (permalink / raw)
  To: Pavel Machek, Greg Kroah-Hartman
  Cc: linux-kernel, linux-serial, linux-leds, kernel

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(-)

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-19 11:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19  8:29 [PATCH 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex Uwe Kleine-König
2021-02-19  8:29 ` [PATCH 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue Uwe Kleine-König
2021-02-19  9:46   ` Pavel Machek
2021-02-19  9:52     ` Uwe Kleine-König
2021-02-19 10:00       ` Pavel Machek
2021-02-19 10:41       ` Greg Kroah-Hartman
2021-02-19 11:23         ` Pavel Machek
2021-02-19  9:46 ` [PATCH 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex Pavel Machek
2021-02-19 10:38 ` kernel test robot
2021-02-19 10:38   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.