Skip to contentSkip to conversation

iio: imu: inv_icm45600: add buffer support in iio devices

bug report Dan Carpenter 2 participants 2 messages Oct 22, 2025 – Oct 31, 2025 IIO

lore
Share & tools
lore
#0 lore raw

Hello Remi Buisson,

Commit 06674a72cf7a ("iio: imu: inv_icm45600: add buffer support in iio devices") from Oct 7, 2025 (linux-next), leads to the following Smatch static checker warning:

	drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c:377 inv_icm45600_buffer_postdisable()
	error: uninitialized symbol 'sleep'.

drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c

    354 static int inv_icm45600_buffer_postdisable(struct iio_dev *indio_dev)
    355 {
    356         struct inv_icm45600_state *st = iio_device_get_drvdata(indio_dev);
    357         struct device *dev = regmap_get_device(st->map);
    358         unsigned int sensor;
    359         unsigned int *watermark;
    360         unsigned int sleep;
    361         int ret;
    362 
    363         if (indio_dev == st->indio_gyro) {
    364                 sensor = INV_ICM45600_SENSOR_GYRO;
    365                 watermark = &st->fifo.watermark.gyro;
    366         } else if (indio_dev == st->indio_accel) {
    367                 sensor = INV_ICM45600_SENSOR_ACCEL;
    368                 watermark = &st->fifo.watermark.accel;
    369         } else {
    370                 return -EINVAL;
    371         }
    372 
    373         scoped_guard(mutex, &st->lock)
    374                 ret = _inv_icm45600_buffer_postdisable(st, sensor, watermark, &sleep);
    375 
    376         /* Sleep required time. */

--> 377 if (sleep)

sleep is only set if _inv_icm45600_buffer_postdisable() succeeds.

    378                 msleep(sleep);
    379 
    380         pm_runtime_put_autosuspend(dev);
    381 
    382         return ret;
    383 }

regards,
dan carpenter

#1 lore raw
Quoted 52 lines

From: Dan Carpenter <[email protected]>
Sent: Wednesday, October 22, 2025 1:05 PM
To: Remi Buisson <[email protected]>
Cc: [email protected]
Subject: [bug report] iio: imu: inv_icm45600: add buffer support in iio devices

Quoted 1 line

Remi Buisson,

Commit 06674a72cf7a ("iio: imu: inv_icm45600: add buffer support in iio devices") from Oct 7, 2025 (linux-next), leads to the following Smatch static checker warning:

	drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c:377 inv_icm45600_buffer_postdisable()
	error: uninitialized symbol 'sleep'.

drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
354 static int inv_icm45600_buffer_postdisable(struct iio_dev *indio_dev)

   355 {
   356         struct inv_icm45600_state *st = iio_device_get_drvdata(indio_dev);
   357         struct device *dev = regmap_get_device(st->map);
   358         unsigned int sensor;
   359         unsigned int *watermark;
   360         unsigned int sleep;
   361         int ret;
   362 
   363         if (indio_dev == st->indio_gyro) {
   364                 sensor = INV_ICM45600_SENSOR_GYRO;
   365                 watermark = &st->fifo.watermark.gyro;
   366         } else if (indio_dev == st->indio_accel) {
   367                 sensor = INV_ICM45600_SENSOR_ACCEL;
   368                 watermark = &st->fifo.watermark.accel;
   369         } else {
   370                 return -EINVAL;
   371         }
   372 
   373         scoped_guard(mutex, &st->lock)
   374                 ret = _inv_icm45600_buffer_postdisable(st, sensor, watermark, &sleep);
   375 
   376         /* Sleep required time. */

--> 377 if (sleep)

sleep is only set if _inv_icm45600_buffer_postdisable() succeeds.

   378                 msleep(sleep);
   379 
   380         pm_runtime_put_autosuspend(dev);
   381 
   382         return ret;
   383 }
Quoted 3 lines

regards,
dan carpenter

Thanks for reporting the issue!
Fixed in change-id: 20251031-icm45600_fix_buffer_sleep_init-8062f6e07f84