[PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target

Qianqiang Liu posted 1 patch 2 months ago
drivers/i2c/busses/i2c-amd-asf-plat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target
Posted by Qianqiang Liu 2 months ago
The len variable is not initialized, which may cause the for loop to
behave unexpectedly.

Fixes: 20c3cc299218 ("i2c: amd-asf: Add routine to handle the ASF slave process")
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 drivers/i2c/busses/i2c-amd-asf-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-amd-asf-plat.c b/drivers/i2c/busses/i2c-amd-asf-plat.c
index 47e0c90341aed..ba47df5370c72 100644
--- a/drivers/i2c/busses/i2c-amd-asf-plat.c
+++ b/drivers/i2c/busses/i2c-amd-asf-plat.c
@@ -61,7 +61,7 @@ static void amd_asf_process_target(struct work_struct *work)
 	unsigned short piix4_smba = dev->port_addr->start;
 	u8 data[ASF_BLOCK_MAX_BYTES];
 	u8 bank, reg, cmd;
-	u8 len, idx, val;
+	u8 len = 0, idx, val;
 
 	/* Read target status register */
 	reg = inb_p(ASFSLVSTA);
-- 
2.39.5
Re: [PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target
Posted by Andi Shyti 1 month, 4 weeks ago
Hi Qianqiang,

On Fri, Sep 27, 2024 at 09:34:44PM GMT, Qianqiang Liu wrote:
> The len variable is not initialized, which may cause the for loop to
> behave unexpectedly.
> 
> Fixes: 20c3cc299218 ("i2c: amd-asf: Add routine to handle the ASF slave process")
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>

This patch is fixing a commit still in i2c/i2c-host.

Applied to i2c/i2c-host.

Thanks,
Andi
Re: [PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target
Posted by Shyam Sundar S K 1 month, 4 weeks ago
Hi,

On 9/27/2024 19:04, Qianqiang Liu wrote:
> The len variable is not initialized, which may cause the for loop to
> behave unexpectedly.
> 
> Fixes: 20c3cc299218 ("i2c: amd-asf: Add routine to handle the ASF slave process")
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>

Thank you for the fix.

Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>

Thanks,
Shyam

> ---
>  drivers/i2c/busses/i2c-amd-asf-plat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-amd-asf-plat.c b/drivers/i2c/busses/i2c-amd-asf-plat.c
> index 47e0c90341aed..ba47df5370c72 100644
> --- a/drivers/i2c/busses/i2c-amd-asf-plat.c
> +++ b/drivers/i2c/busses/i2c-amd-asf-plat.c
> @@ -61,7 +61,7 @@ static void amd_asf_process_target(struct work_struct *work)
>  	unsigned short piix4_smba = dev->port_addr->start;
>  	u8 data[ASF_BLOCK_MAX_BYTES];
>  	u8 bank, reg, cmd;
> -	u8 len, idx, val;
> +	u8 len = 0, idx, val;
>  
>  	/* Read target status register */
>  	reg = inb_p(ASFSLVSTA);
Re: [PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target
Posted by Qianqiang Liu 1 month, 4 weeks ago
Hi Andi,

Could you please review this patch?

-- 
Best,
Qianqiang Liu
Re: [PATCH v2] i2c: amd-asf: Fix uninitialized variables issue in amd_asf_process_target
Posted by Dan Carpenter 2 months ago
On Fri, Sep 27, 2024 at 09:34:44PM +0800, Qianqiang Liu wrote:
> The len variable is not initialized, which may cause the for loop to
> behave unexpectedly.
> 
> Fixes: 20c3cc299218 ("i2c: amd-asf: Add routine to handle the ASF slave process")
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter