Skip to content

Commit 655a8a7

Browse files
tititiou36Jiri Kosina
authored andcommitted
HID: nintendo: Fix an error handling path in nintendo_hid_probe()
joycon_leds_create() has a ida_alloc() call. So if an error occurs after it, a corresponding ida_free() call is needed, as already done in the .remove function. This is not 100% perfect, because if ida_alloc() fails, then 'ctlr->player_id' will forced to be U32_MAX, and an error will be logged when ida_free() is called. Considering that this can't happen in real life, no special handling is done to handle it. Fixes: 5307de6 ("HID: nintendo: use ida for LED player id") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Silvan Jegen <s.jegen@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent ce3af2e commit 655a8a7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/hid/hid-nintendo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,20 +2725,22 @@ static int nintendo_hid_probe(struct hid_device *hdev,
27252725
ret = joycon_power_supply_create(ctlr);
27262726
if (ret) {
27272727
hid_err(hdev, "Failed to create power_supply; ret=%d\n", ret);
2728-
goto err_close;
2728+
goto err_ida;
27292729
}
27302730

27312731
ret = joycon_input_create(ctlr);
27322732
if (ret) {
27332733
hid_err(hdev, "Failed to create input device; ret=%d\n", ret);
2734-
goto err_close;
2734+
goto err_ida;
27352735
}
27362736

27372737
ctlr->ctlr_state = JOYCON_CTLR_STATE_READ;
27382738

27392739
hid_dbg(hdev, "probe - success\n");
27402740
return 0;
27412741

2742+
err_ida:
2743+
ida_free(&nintendo_player_id_allocator, ctlr->player_id);
27422744
err_close:
27432745
hid_hw_close(hdev);
27442746
err_stop:

0 commit comments

Comments
 (0)