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 <maxxliferobot@gmail.com>
This commit is contained in:
Maksim Masalski 2019-02-21 11:23:51 +03:00 committed by Anas Nashif
commit 039d8ecf6a

View file

@ -97,7 +97,7 @@ static u32_t get_timeout(u32_t timeout)
count++;
}
return count - 1;
return ((count > 1U) ? (count - 1U) : 0);
}
static int wdt_qmsi_install_timeout(struct device *dev,