projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a269c3e
)
hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms
author
Jason A. Donenfeld
<Jason@zx2c4.com>
Sat, 24 Sep 2022 10:11:51 +0000
(12:11 +0200)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:35:37 +0000
(12:35 +0200)
[ Upstream commit
f9c0cf8f26de367c58e48b02b1cdb9c377626e6f
]
On 32-bit platforms, long is 32 bits, so (long)UINT_MAX is less than
(long)SHT4X_MIN_POLL_INTERVAL, which means the clamping operation is
bogus. Fix this by clamping at INT_MAX, so that the upperbound is the
same on all platforms.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link:
https://lore.kernel.org/r/20220924101151.4168414-1-Jason@zx2c4.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/sht4x.c
patch
|
blob
|
history
diff --git
a/drivers/hwmon/sht4x.c
b/drivers/hwmon/sht4x.c
index 09c2a0b0644440d0cd27e29236c3678621593780..9aeb3dbf6c20842d8c967771c3f76182f6673cbf 100644
(file)
--- a/
drivers/hwmon/sht4x.c
+++ b/
drivers/hwmon/sht4x.c
@@
-129,7
+129,7
@@
unlock:
static ssize_t sht4x_interval_write(struct sht4x_data *data, long val)
{
- data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL,
U
INT_MAX);
+ data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, INT_MAX);
return 0;
}