lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 18 Jul 2022 11:25:12 +0200
From:   Artur Rojek <contact@...ur-rojek.eu>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     Jonathan Cameron <jic23@...nel.org>, linux-kernel@...r.kernel.org,
        linux-input@...r.kernel.org
Subject: Re: [PATCH] Input: adc-joystick - fix ordering in
 adc_joystick_probe()

On 2022-07-09 06:35, Dmitry Torokhov wrote:
> 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.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> ---
> 
> Not tested on hardware...
Hi Dmitry,

nice catch, thanks! I will verify the operation on hardware some time 
over the weekend.
Small nitpick inline. With that changed:

Acked-by: Artur Rojek <contact@...ur-rojek.eu>

> 
>  drivers/input/joystick/adc-joystick.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/input/joystick/adc-joystick.c
> b/drivers/input/joystick/adc-joystick.c
> index 78ebca7d400a..e0cfdc84763f 100644
> --- a/drivers/input/joystick/adc-joystick.c
> +++ b/drivers/input/joystick/adc-joystick.c
> @@ -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");
> @@ -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;
Since this is now the last thing the function does, we can simplify the 
code a bit:
```
	error = input_register_device(input);
	if (error)
		dev_err(dev, "Unable to register input device\n");

	return error;
```

Cheers,
Artur
>  }
> 
> --
> 2.37.0.144.g8ac04bfd2-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ