summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-07-25 15:01:28 -0700
committerGuenter Roeck <linux@roeck-us.net>2016-07-31 15:02:51 -0700
commit4c8702b3cd43322ca97fdc7f647e273a7388a0c6 (patch)
tree80c69ea951c3763589a8d6775244c130d7aaa073 /drivers/hwmon
parent1aa4f0289fd5554a9cd58e5b47a361b14256ea90 (diff)
downloadlinux-0-day-4c8702b3cd43322ca97fdc7f647e273a7388a0c6.tar.gz
linux-0-day-4c8702b3cd43322ca97fdc7f647e273a7388a0c6.tar.xz
hwmon: (ftsteutates) Fix potential memory access error
Using set_bit() to set a bit in an integer is not a good idea, since the function expects an unsigned long as argument, which can be 64 bit wide. Coverity reports this problem as >>> CID 1364488: Memory - illegal accesses (INCOMPATIBLE_CAST) >>> Pointer "&ret" points to an object whose effective type is "int" >>> (32 bits, signed) but is dereferenced as a wider "unsigned +long" (64 bits, unsigned). This may lead to memory corruption. 245 set_bit(1, (unsigned long *)&ret); Just use BIT instead. Cc: Thilo Cestonaro <thilo@cestona.ro> Fixes: 08426eda58e0 ("hwmon: Add driver for FTS BMC chip "Teutates"") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ftsteutates.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c
index 2b2ff67026be9..48633e541dc35 100644
--- a/drivers/hwmon/ftsteutates.c
+++ b/drivers/hwmon/ftsteutates.c
@@ -242,7 +242,7 @@ static int fts_wd_set_resolution(struct fts_data *data,
}
if (resolution == seconds)
- set_bit(1, (unsigned long *)&ret);
+ ret |= BIT(1);
else
ret &= ~BIT(1);