Skip to content

Commit 587b48b

Browse files
harshimogalapalligregkh
authored andcommitted
iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word()
[ Upstream commit 64a6815 ] Smatch Warns: drivers/iio/accel/mma9551_core.c:299 mma9551_read_config_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: No actual bug as caller checks the return value and does not use the 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2b59fdc commit 587b48b

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
@@ -296,9 +296,12 @@ int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
296296

297297
ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_CONFIG,
298298
reg, NULL, 0, (u8 *)&v, 2);
299+
if (ret < 0)
300+
return ret;
301+
299302
*val = be16_to_cpu(v);
300303

301-
return ret;
304+
return 0;
302305
}
303306
EXPORT_SYMBOL(mma9551_read_config_word);
304307

0 commit comments

Comments
 (0)