Skip to content

Commit 039d8ec

Browse files
maxxlifenashif
authored andcommitted
drivers: Changed return statement in function get_timeout()
According to the Coverity issue 188890 (github issue #10705) Fix for overflowed or truncated value count-1U used as return value. I decided to use a saturating subtract to avoid a vulnerability. It will always return 0 or bigger value according to the conditions. Now if count value is 0, function will return 0, not -1 as before. Signed-off-by: Maksim Masalski <[email protected]>
1 parent 630af8a commit 039d8ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/watchdog/wdt_qmsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static u32_t get_timeout(u32_t timeout)
9797
count++;
9898
}
9999

100-
return count - 1;
100+
return ((count > 1U) ? (count - 1U) : 0);
101101
}
102102

103103
static int wdt_qmsi_install_timeout(struct device *dev,

0 commit comments

Comments
 (0)