Skip to content

Commit

Permalink
Input: adc-joystick - fix ordering in adc_joystick_probe()
Browse files Browse the repository at this point in the history
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 <contact@artur-rojek.eu>
Link: https://lore.kernel.org/r/YskFh4NHnlcryMkk@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Dmitry Torokhov committed Aug 2, 2022
1 parent e4bb7fe commit 7c744d0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/input/joystick/adc-joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ static int adc_joystick_probe(struct platform_device *pdev)
if (error)
return error;

input_set_drvdata(input, joy);
error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device\n");
return error;
}

joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy);
if (IS_ERR(joy->buffer)) {
dev_err(dev, "Unable to allocate callback buffer\n");
Expand All @@ -241,6 +234,14 @@ static int adc_joystick_probe(struct platform_device *pdev)
return error;
}

input_set_drvdata(input, joy);

error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device\n");
return error;
}

return 0;
}

Expand Down

0 comments on commit 7c744d0

Please sign in to comment.