Re: [PATCH v2] iio: imu: inv_icm45600: Initializes inv_icm45600_buffer_postdisable sleep
From: Andy Shevchenko
Date: Fri Oct 31 2025 - 10:40:25 EST
On Fri, Oct 31, 2025 at 01:57:06PM +0000, Remi Buisson via B4 Relay wrote:
>
> The sleep variable in inv_icm45600_buffer_postdisable could be used without
> being assigned in case of error. It must be initialized to 0 by default.
> Fixes: 06674a72cf7a ("iio: imu: inv_icm45600: add buffer support in iio devices")
This is part of the tag block, needs to go together (on one paragraph, means no
blank lines in between) with your SoB and other tags, if applicable.
> Smatch static checker warning:
>
> drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c:377 inv_icm45600_buffer_postdisable()
> error: uninitialized symbol 'sleep'.
Is there a public message / report on this? If so, use Closes: tag to point to
it.
> Signed-off-by: Remi Buisson <remi.buisson@xxxxxxx>
...
> struct device *dev = regmap_get_device(st->map);
> unsigned int sensor;
> unsigned int *watermark;
> - unsigned int sleep;
> + unsigned int sleep = 0;
As I said, the preferred way is to decouple definition and assignment. The best
place for it is just before scope_guard() call.
sleep = 0;
scoped_guard(mutex, &st->lock)
ret = _inv_icm45600_buffer_postdisable(st, sensor, watermark, &sleep);
--
With Best Regards,
Andy Shevchenko