HID: nintendo: Fix an error handling path in nintendo_hid_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 26 May 2024 15:05:59 +0000 (17:05 +0200)
committerJiri Kosina <jkosina@suse.com>
Tue, 4 Jun 2024 14:16:37 +0000 (16:16 +0200)
commit655a8a7684b897721f87c59798fd04d8b79f1b69
treea234607f76e76193679210c5950c142b12f9db4f
parentce3af2ee95170b7d9e15fff6e500d67deab1e7b3
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>
drivers/hid/hid-nintendo.c