Skip to content

Commit e56d2c3

Browse files
harshimogalapallijic23
authored andcommitted
iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word()
Smatch Warns: drivers/iio/accel/mma9551_core.c:357 mma9551_read_status_word() error: uninitialized symbol 'v'. When (offset >= 1 << 12) is true mma9551_transfer() will return -EINVAL without 'v' being initialized, so check for the error and return. Note: Not a bug as such because the caller checks return value and doesn't not use this parameter in the problem case. Signed-off-by: Harshit Mogalapalli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent b186b18 commit e56d2c3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/iio/accel/mma9551_core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,12 @@ int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
354354

355355
ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_STATUS,
356356
reg, NULL, 0, (u8 *)&v, 2);
357+
if (ret < 0)
358+
return ret;
359+
357360
*val = be16_to_cpu(v);
358361

359-
return ret;
362+
return 0;
360363
}
361364
EXPORT_SYMBOL_NS(mma9551_read_status_word, IIO_MMA9551);
362365

0 commit comments

Comments
 (0)