1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-05 09:14:03 +00:00

Guard against overflow of the calculated timeout value.

This commit is contained in:
Matt Jacob 2001-01-16 07:15:36 +00:00
parent 248c2e72aa
commit d69a5f7d9c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71094

View File

@ -1502,14 +1502,19 @@ isp_action(struct cam_sim *sim, union ccb *ccb)
case CMD_QUEUED:
ccb->ccb_h.status |= CAM_SIM_QUEUED;
if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
int ticks;
u_int64_t ticks = (u_int64_t) hz;
if (ccb->ccb_h.timeout == CAM_TIME_DEFAULT)
ticks = 60 * 1000 * hz;
ticks = 60 * 1000 * ticks;
else
ticks = ccb->ccb_h.timeout * hz;
ticks = ((ticks + 999) / 1000) + hz + hz;
ccb->ccb_h.timeout_ch =
timeout(isp_watchdog, (caddr_t)ccb, ticks);
if (ticks >= 0x80000000) {
isp_prt(isp, ISP_LOGERR,
"timeout overflow");
ticks = 0x80000000;
}
ccb->ccb_h.timeout_ch = timeout(isp_watchdog,
(caddr_t)ccb, (int)ticks);
} else {
callout_handle_init(&ccb->ccb_h.timeout_ch);
}