diff options
| author | xueqin Luo <luoxueqin@kylinos.cn> | 2024-12-02 11:19:16 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-08 10:01:20 +0100 |
| commit | aa6671db2d2899e720847183280eca6fb10fe340 (patch) | |
| tree | 37baf86de44b973b976e53c85b776b51783dc5f0 /drivers | |
| parent | c26382ed62ba8d6f583d59dadaa07a3ef5425703 (diff) | |
| download | linux-aa6671db2d2899e720847183280eca6fb10fe340.tar.gz linux-aa6671db2d2899e720847183280eca6fb10fe340.tar.bz2 linux-aa6671db2d2899e720847183280eca6fb10fe340.zip | |
wifi: mt76: mt7996: fix overflows seen when writing limit attributes
[ Upstream commit 5adbc8ce5bbe7e311e2600b7d7d998a958873e98 ]
DIV_ROUND_CLOSEST() after kstrtoul() results in an overflow if a large
number such as 18446744073709551615 is provided by the user.
Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.
This commit was inspired by commit: 57ee12b6c514.
Fixes: 6879b2e94172 ("wifi: mt76: mt7996: add thermal sensor device support")
Signed-off-by: xueqin Luo <luoxueqin@kylinos.cn>
Link: https://patch.msgid.link/20241202031917.23741-2-luoxueqin@kylinos.cn
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7996/init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c index efa7b0697a40..d5f53abc4dcb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c @@ -82,7 +82,7 @@ static ssize_t mt7996_thermal_temp_store(struct device *dev, return ret; mutex_lock(&phy->dev->mt76.mutex); - val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 40, 130); + val = DIV_ROUND_CLOSEST(clamp_val(val, 40 * 1000, 130 * 1000), 1000); /* add a safety margin ~10 */ if ((i - 1 == MT7996_CRIT_TEMP_IDX && |
