Skip to content

Commit 7c744d0

Browse files
committed
Input: adc-joystick - fix ordering in adc_joystick_probe()
We should register the IIO buffer before we register the input device, because as soon as the device is registered input handlers may attach to it, resulting in a call to adc_joystick_open() which makes use of the said buffer. Acked-by: Artur Rojek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent e4bb7fe commit 7c744d0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/input/joystick/adc-joystick.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,6 @@ static int adc_joystick_probe(struct platform_device *pdev)
222222
if (error)
223223
return error;
224224

225-
input_set_drvdata(input, joy);
226-
error = input_register_device(input);
227-
if (error) {
228-
dev_err(dev, "Unable to register input device\n");
229-
return error;
230-
}
231-
232225
joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy);
233226
if (IS_ERR(joy->buffer)) {
234227
dev_err(dev, "Unable to allocate callback buffer\n");
@@ -241,6 +234,14 @@ static int adc_joystick_probe(struct platform_device *pdev)
241234
return error;
242235
}
243236

237+
input_set_drvdata(input, joy);
238+
239+
error = input_register_device(input);
240+
if (error) {
241+
dev_err(dev, "Unable to register input device\n");
242+
return error;
243+
}
244+
244245
return 0;
245246
}
246247

0 commit comments

Comments
 (0)