mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2025-12-09 06:02:10 -05:00
realtek: pcs: Fix overflow in rtpcs_930x_sds_clock_wait
It can happen that the calculation `start + (HZ / 1000) * timeout` overflows `unsigned long`. This must be handled correctly to avoid too long waits. Luckily, the `time_before()` helper already does this. Signed-off-by: Sven Eckelmann <sven@narfation.org> Link: https://github.com/openwrt/openwrt/pull/20906 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
69c6658c73
commit
d5fec0b125
@ -685,13 +685,14 @@ static int rtpcs_930x_sds_clock_wait(struct rtpcs_ctrl *ctrl, int timeout)
|
||||
{
|
||||
u32 v;
|
||||
unsigned long start = jiffies;
|
||||
unsigned long end = start + (HZ / 1000) * timeout;
|
||||
|
||||
do {
|
||||
rtpcs_sds_write_bits(ctrl, 2, 0x1f, 0x2, 15, 0, 53);
|
||||
v = rtpcs_sds_read_bits(ctrl, 2, 0x1f, 20, 5, 4);
|
||||
if (v == 3)
|
||||
return 0;
|
||||
} while (jiffies < start + (HZ / 1000) * timeout);
|
||||
} while (time_before(jiffies, end));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user