[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2nyxcv7yearclljgnqrrrobburq7cvqog46ct56lvtn4zux6z7@twxxpmbuce3c>
Date: Thu, 24 Oct 2024 01:02:30 +0200
From: Andi Shyti <andi.shyti@...nel.org>
To: Suraj Sonawane <surajsonawane0215@...il.com>
Cc: tharunkumar.pasumarthi@...rochip.com,
kumaravel.thiagarajan@...rochip.com, UNGLinuxDriver@...rochip.com, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: busses: fix uninit-value in pci1xxxx_i2c_xfer
Hi Suraj,
Thanks for your patch, but...
On Wed, Oct 23, 2024 at 12:38:45AM +0530, Suraj Sonawane wrote:
> Fix an issue reported by the smatch static analysis tool:
> drivers/i2c/busses/i2c-mchp-pci1xxxx.c:1030 pci1xxxx_i2c_xfer() error:
> uninitialized symbol 'retval'.
>
> The error occurs because retval may be used without being set if the
> transfer loop does not execute (e.g., when num is 0). This could cause
> the function to return an undefined value, leading to unpredictable
> behavior.
... if num is '0', then we would never reach here, check
__i2c_transfer().
Thanks,
Andi
> Initialize retval to 0 before the transfer loop to ensure that the
> function returns a valid value even if no transfers are processed. This
> change also preserves proper error handling within the loop.
>
> Signed-off-by: Suraj Sonawane <surajsonawane0215@...il.com>
Powered by blists - more mailing lists