summaryrefslogtreecommitdiffstats
path: root/sys/dev/arcmsr/arcmsr.c
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2014-11-21 21:01:24 +0000
committersmh <smh@FreeBSD.org>2014-11-21 21:01:24 +0000
commitdd63bf99a2e07e9e0fae2c230c2dc6505f21618d (patch)
tree5ebdafcf9900ec8ee871257dadfca8fdc7f4aa95 /sys/dev/arcmsr/arcmsr.c
parent463d37d4caf476e9ea1220f380eb22393c7fff11 (diff)
downloadFreeBSD-src-dd63bf99a2e07e9e0fae2c230c2dc6505f21618d.zip
FreeBSD-src-dd63bf99a2e07e9e0fae2c230c2dc6505f21618d.tar.gz
Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the signed integer, will give weird results, since callout(9) routines will convert negative values of ticks to '1'. For unsigned integer overflow we will get sufficiently smaller timeout values than expected. Switch from callout_reset, which requires conversion to int based ticks to callout_reset_sbt to avoid this. Also correct isci to correctly resolve ccb timeout. This was based on the original work done by Eygene Ryabinkin <rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid the overlow. Differential Revision: https://reviews.freebsd.org/D1157 Reviewed by: mav, davide MFC after: 1 month Sponsored by: Multiplay
Diffstat (limited to 'sys/dev/arcmsr/arcmsr.c')
-rw-r--r--sys/dev/arcmsr/arcmsr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index 4c9210e..f9885d3 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -2705,7 +2705,9 @@ static void arcmsr_execute_srb(void *arg, bus_dma_segment_t *dm_segs, int nseg,
if (pccb->ccb_h.timeout != CAM_TIME_INFINITY)
{
arcmsr_callout_init(&srb->ccb_callout);
- callout_reset(&srb->ccb_callout, ((pccb->ccb_h.timeout + (ARCMSR_TIMEOUT_DELAY * 1000)) * hz) / 1000, arcmsr_srb_timeout, srb);
+ callout_reset_sbt(&srb->ccb_callout, SBT_1MS *
+ (pccb->ccb_h.timeout + (ARCMSR_TIMEOUT_DELAY * 1000)), 0,
+ arcmsr_srb_timeout, srb, 0);
srb->srb_flags |= SRB_FLAG_TIMER_START;
}
}
OpenPOWER on IntegriCloud