]> git.karo-electronics.de Git - karo-tx-linux.git/commit
hwmon: (w83627ehf) Get rid of smatch warnings
authorJean Delvare <khali@linux-fr.org>
Mon, 5 Nov 2012 22:54:44 +0000 (09:54 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 5 Nov 2012 22:54:44 +0000 (09:54 +1100)
commit2d4a224ca251fbb46e7900b4554563b1071eed13
treef6fe3c06a1a6979d698b781b9b4d1ff35bf13fb9
parent6d6ab6d75c0428083b51b59c5533b3fd161d43a0
hwmon: (w83627ehf) Get rid of smatch warnings

The smatch static code analyzer complains:

drivers/hwmon/w83627ehf.c:911 w83627ehf_update_device() error: buffer overflow 'W83627EHF_REG_TEMP_OFFSET' 3 <= 8
drivers/hwmon/w83627ehf.c:909 w83627ehf_update_device() error: buffer overflow 'data->temp_offset' 3 <= 8
drivers/hwmon/w83627ehf.c:2672 w83627ehf_resume() error: buffer overflow 'W83627EHF_REG_TEMP_OFFSET' 3 <= 8
drivers/hwmon/w83627ehf.c:2673 w83627ehf_resume() error: buffer overflow 'data->temp_offset' 3 <= 8

A deeper analysis of the code shows that these are false positives, as
only the lower 3 bits of data->have_temp_offset can be set so the
write is never attempted with i >= 3. However this shows that the code
isn't very robust and future changes could easily introduce a buffer
overflow. So let's add a safety check to prevent that and make smatch
happy.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Peter Huewe <PeterHuewe@gmx.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/w83627ehf.c