Skip to content

Commit

Permalink
HID: nintendo: unlock on error in joycon_leds_create()
Browse files Browse the repository at this point in the history
These two error paths need to drop the lock before returning.

Fixes: c5e6267 ("HID: nintendo: add player led support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Dan Carpenter authored and Jiri Kosina committed Nov 10, 2021
1 parent f155dfe commit 304dd36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/hid/hid-nintendo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 304dd36

Please sign in to comment.