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]
Message-ID: <5uzgfsbupxt3p4hlvi6atdzdamcuci2u3k7zl2zic5qrphl6yn@duygfftdrnh6>
Date: Sat, 6 Jul 2024 00:48:49 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Chen Ni <nichen@...as.ac.cn>
Cc: dmitry.torokhov@...il.com, Jonathan.Cameron@...wei.com, 
	broonie@...nel.org, linux-input@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-spi@...r.kernel.org
Subject: Re: [PATCH] Input: pxspad - add check for spi_setup

Hello,

[Cc += linux-spi]

On Fri, Jul 05, 2024 at 04:20:57PM +0800, Chen Ni wrote:
> Add check for the return value of spi_setup() and return the error
> if it fails in order to catch the error.

Does this fix a real-world problem, or did you notice this using a
linter or by just reading through the driver?

> Signed-off-by: Chen Ni <nichen@...as.ac.cn>
> ---
>  drivers/input/joystick/psxpad-spi.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
> index c47fc5f34bd0..5b53d43c797a 100644
> --- a/drivers/input/joystick/psxpad-spi.c
> +++ b/drivers/input/joystick/psxpad-spi.c
> @@ -344,7 +344,11 @@ static int psxpad_spi_probe(struct spi_device *spi)
>  	/* (PlayStation 1/2 joypad might be possible works 250kHz/500kHz) */
>  	spi->controller->min_speed_hz = 125000;
>  	spi->controller->max_speed_hz = 125000;
> -	spi_setup(spi);
> +	err = spi_setup(spi);
> +	if (err < 0) {
> +		dev_err(&spi->dev, "failed to set up spi: %d\n", err);
> +		return err;

Please consider using dev_err_probe() in such cases. It allows for a
more compact error path and emits the error code in a human readable
way.

Apart from that: spi_setup() is inconsistent as it emits error messages
for some error paths but not for all. Probably the better change is to
make spi_setup() consistent here. I suggest to add error messages to the
error paths that currently don't have a message and drop this patch.

Best regards
Uwe

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ