diff mbox series

HID: nintendo: unlock on error in joycon_leds_create()

Message ID 20211110081208.GH5176@kili (mailing list archive)
State Mainlined
Commit 304dd3680b56a2a5c8eaff41bcf1a3e49adf7dfc
Delegated to: Jiri Kosina
Headers show
Series HID: nintendo: unlock on error in joycon_leds_create() | expand

Commit Message

Dan Carpenter Nov. 10, 2021, 8:12 a.m. UTC
These two error paths need to drop the lock before returning.

Fixes: c5e626769563 ("HID: nintendo: add player led support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/hid/hid-nintendo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jiri Kosina Nov. 10, 2021, 9 a.m. UTC | #1
On Wed, 10 Nov 2021, Dan Carpenter wrote:

> These two error paths need to drop the lock before returning.
> 
> Fixes: c5e626769563 ("HID: nintendo: add player led support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for spotting it; applied.
diff mbox series

Patch

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index a1e0f6849875..7e1d1127493e 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)
+		if (!name) {
+			mutex_unlock(&joycon_input_num_mutex);
 			return -ENOMEM;
+		}
 
 		led = &ctlr->leds[i];
 		led->name = name;
@@ -1864,6 +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);
+			mutex_unlock(&joycon_input_num_mutex);
 			return ret;
 		}
 	}