All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] HID: nintendo: fix missing unlock on error in joycon_leds_create()
@ 2021-10-29  3:10 Yang Yingliang
  2021-10-29 12:07 ` Silvan Jegen
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-10-29  3:10 UTC (permalink / raw)
  To: linux-kernel, linux-input; +Cc: benjamin.tissoires, jikos, djogorchock

Add the missing unlock before return from function joycon_leds_create()
in the error handling case.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: c5e626769563 ("HID: nintendo: add player led support")
Fixes: 697e5c7a34b0 ("HID: nintendo: add home led support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hid/hid-nintendo.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index c4270499fc6f..ddfb001a8fc9 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -1850,8 +1850,10 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
 				      d_name,
 				      "green",
 				      joycon_player_led_names[i]);
-		if (!name)
-			return -ENOMEM;
+		if (!name) {
+			ret = -ENOMEM;
+			goto err_unlock;
+		}
 
 		led = &ctlr->leds[i];
 		led->name = name;
@@ -1864,7 +1866,7 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
 		ret = devm_led_classdev_register(&hdev->dev, led);
 		if (ret) {
 			hid_err(hdev, "Failed registering %s LED\n", led->name);
-			return ret;
+			goto err_unlock;
 		}
 	}
 
@@ -1902,6 +1904,10 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
 	}
 
 	return 0;
+
+err_unlock:
+	mutex_unlock(&joycon_input_num_mutex);
+	return ret;
 }
 
 static int joycon_battery_get_property(struct power_supply *supply,
-- 
2.25.1


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

* Re: [PATCH -next] HID: nintendo: fix missing unlock on error in joycon_leds_create()
  2021-10-29  3:10 [PATCH -next] HID: nintendo: fix missing unlock on error in joycon_leds_create() Yang Yingliang
@ 2021-10-29 12:07 ` Silvan Jegen
  0 siblings, 0 replies; 2+ messages in thread
From: Silvan Jegen @ 2021-10-29 12:07 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: lkml, linux-input, Benjamin Tissoires, Jiri Kosina, Daniel J. Ogorchock

On Fri, Oct 29, 2021 at 5:04 AM Yang Yingliang <yangyingliang@huawei.com> wrote:
>
> Add the missing unlock before return from function joycon_leds_create()
> in the error handling case.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: c5e626769563 ("HID: nintendo: add player led support")
> Fixes: 697e5c7a34b0 ("HID: nintendo: add home led support")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/hid/hid-nintendo.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

LGTM!

For what it's worth:

Reviewed-by: Silvan Jegen <s.jegen@gmail.com>


Cheers,
Silvan

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

end of thread, other threads:[~2021-10-29 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29  3:10 [PATCH -next] HID: nintendo: fix missing unlock on error in joycon_leds_create() Yang Yingliang
2021-10-29 12:07 ` Silvan Jegen

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.