mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
HID: nintendo: register input device after capabilities are set
input_register_device() exposes the device to userspace immediately.
In joycon_input_create() it was called before joycon_config_rumble()
configures the FF_RUMBLE capability and the memless force-feedback
device, so a concurrent EVIOCSFF could dereference a NULL dev->ff.
Registering early also means the initial udev event lacks button and
axis information, which can make input managers ignore the device.
Move input_register_device() to the end of joycon_input_create(), after
all capabilities, the IMU input device and the force-feedback callbacks
have been configured.
Fixes: 2af16c1f84 ("HID: nintendo: add nintendo switch controller driver")
Reported-by: sashiko-bot@kernel.org
Closes: https://sashiko.dev/#/patchset/20260730031927.25444-1-yijiangshan@kylinos.cn?part=1
Cc: stable@vger.kernel.org
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Link: https://sashiko.dev/#/patchset/20260730031927.25444-1-yijiangshan@kylinos.cn?part=1
Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
781f8e020a
commit
d723bc1fe2
|
|
@ -2198,10 +2198,6 @@ static int joycon_input_create(struct joycon_ctlr *ctlr)
|
|||
ctlr->input->phys = hdev->phys;
|
||||
input_set_drvdata(ctlr->input, ctlr);
|
||||
|
||||
ret = input_register_device(ctlr->input);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (joycon_type_is_right_joycon(ctlr)) {
|
||||
joycon_config_right_stick(ctlr->input);
|
||||
joycon_config_buttons(ctlr->input, right_joycon_button_mappings);
|
||||
|
|
@ -2244,6 +2240,10 @@ static int joycon_input_create(struct joycon_ctlr *ctlr)
|
|||
if (joycon_has_rumble(ctlr))
|
||||
joycon_config_rumble(ctlr);
|
||||
|
||||
ret = input_register_device(ctlr->input);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user