drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Remi Buisson <remi.buisson@tdk.com>
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")
Smatch static checker warning:
drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c:377 inv_icm45600_buffer_postdisable()
error: uninitialized symbol 'sleep'.
Signed-off-by: Remi Buisson <remi.buisson@tdk.com>
---
Changes in v2:
- Moving pacth description from cover-letter to single commit
- Link to v1: https://lore.kernel.org/r/20251031-icm45600_fix_buffer_sleep_init-v1-1-924efbb165e8@tdk.com
---
drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c b/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
index 2efcc177f9d60a6a2509e448c0ddaf4b9e1fd755..bb8382feddc0fd882a6be2ce5e4fe77ab68f13fd 100644
--- a/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
+++ b/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
@@ -357,7 +357,7 @@ static int inv_icm45600_buffer_postdisable(struct iio_dev *indio_dev)
struct device *dev = regmap_get_device(st->map);
unsigned int sensor;
unsigned int *watermark;
- unsigned int sleep;
+ unsigned int sleep = 0;
int ret;
if (indio_dev == st->indio_gyro) {
---
base-commit: 70437bbd7529e9860fb7f0c92a89e0e6abaa994e
change-id: 20251031-icm45600_fix_buffer_sleep_init-8062f6e07f84
Best regards,
--
Remi Buisson <remi.buisson@tdk.com>
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@tdk.com>
...
> 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
© 2016 - 2026 Red Hat, Inc.