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] [thread-next>] [day] [month] [year] [list]
Message-ID: <kmcsuqlmawjqvixoevqa2waf2smznvbtbgw7drlbwgegfojz5x@vziujze5nzsb>
Date: Tue, 20 May 2025 10:41:52 +0200
From: Andi Shyti <andi.shyti@...nel.org>
To: Wentao Liang <vulab@...as.ac.cn>
Cc: linux-arm-msm@...r.kernel.org, linux-i2c@...r.kernel.org, 
	linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] i2c: qup: Add error handling in qup_i2c_xfer_v2()

Hi Wentao,

On Mon, May 19, 2025 at 10:19:18PM +0800, Wentao Liang wrote:
> The qup_i2c_xfer_v2() calls the qup_i2c_change_state() but does
> not check its return value. A proper implementation can be
> found in qup_i2c_xfer().
> 
> Add error handling for qup_i2c_change_state(). If the function
> fails, return the error code.
> 
> Fixes: 7545c7dba169 ("i2c: qup: reorganization of driver code to remove polling for qup v2")
> Cc: stable@...r.kernel.org # v4.17

no need to Cc stable here, it's not such a big issue.

> Signed-off-by: Wentao Liang <vulab@...as.ac.cn>
> ---
>  drivers/i2c/busses/i2c-qup.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index da20b4487c9a..2477f570fe86 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -1538,7 +1538,7 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap,
>  			   int num)
>  {
>  	struct qup_i2c_dev *qup = i2c_get_adapdata(adap);
> -	int ret, idx = 0;
> +	int ret, err, idx = 0;
>  
>  	qup->bus_err = 0;
>  	qup->qup_err = 0;
> @@ -1588,7 +1588,9 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap,
>  		ret = qup_i2c_bus_active(qup, ONE_BYTE);
>  
>  	if (!ret)
> -		qup_i2c_change_state(qup, QUP_RESET_STATE);
> +		err = qup_i2c_change_state(qup, QUP_RESET_STATE);

This check was removed on purpose, not by accident in the commit
you pointed out in the Fixes tag. On the other hand I agree that
this needs to be checked, perhaps restoring the original code:

	if (!ret)
		ret = qup_i2c_change_state(qup, QUP_RESET_STATE);

	if (ret == 0)
		ret = num;

What is exactly that you are trying to fix here? What is the
error you have faced?

Thanks,
Andi

> +	if (err)
> +		return err;
>  
>  	if (ret == 0)
>  		ret = num;

PS: your code can be refactored in a way that we don't need this
extra variable. E.g., something like this:

	if (!ret)
		ret = qup_i2c_bus_active(qup, ONE_BYTE);

	if (!ret) {
		ret = qup_i2c_change_state(qup, QUP_RESET_STATE);
		if (ret)
			return ret;
		ret = num;
	}

Looks the same, no? But I think the original version should work
better.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ