Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 5307de63d71d ("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>

authored by

Christophe JAILLET and committed by
Jiri Kosina
655a8a76 ce3af2ee

+4 -2
+4 -2
drivers/hid/hid-nintendo.c
··· 2725 2725 ret = joycon_power_supply_create(ctlr); 2726 2726 if (ret) { 2727 2727 hid_err(hdev, "Failed to create power_supply; ret=%d\n", ret); 2728 - goto err_close; 2728 + goto err_ida; 2729 2729 } 2730 2730 2731 2731 ret = joycon_input_create(ctlr); 2732 2732 if (ret) { 2733 2733 hid_err(hdev, "Failed to create input device; ret=%d\n", ret); 2734 - goto err_close; 2734 + goto err_ida; 2735 2735 } 2736 2736 2737 2737 ctlr->ctlr_state = JOYCON_CTLR_STATE_READ; ··· 2739 2739 hid_dbg(hdev, "probe - success\n"); 2740 2740 return 0; 2741 2741 2742 + err_ida: 2743 + ida_free(&nintendo_player_id_allocator, ctlr->player_id); 2742 2744 err_close: 2743 2745 hid_hw_close(hdev); 2744 2746 err_stop: