]> git.baikalelectronics.ru Git - kernel.git/commit
iio: maxim_thermocouple: detect invalid storage size in read()
authorArnd Bergmann <arnd@arndb.de>
Tue, 25 Oct 2016 15:55:04 +0000 (17:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Nov 2016 09:08:32 +0000 (10:08 +0100)
commitddbc454b775a5c530b2b665b195f9280e19fd996
tree7a89a59446a40d720a83a77b4dd92f1fd081bc44
parent87adb60c60f609c6a3db03644abed0f396ffd5ea
iio: maxim_thermocouple: detect invalid storage size in read()

As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other
than 2 or 4 will result in undefined behavior:

drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read':
drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This probably cannot happen, but returning -EINVAL here is appropriate
and makes gcc happy and the code more robust.

Fixes: 10f5ee3c74fa ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
(cherry picked from commit 32cb7d27e65df9daa7cee8f1fdf7b259f214bee2)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/temperature/maxim_thermocouple.c