diff options
author | smh <smh@FreeBSD.org> | 2014-12-21 03:06:11 +0000 |
---|---|---|
committer | smh <smh@FreeBSD.org> | 2014-12-21 03:06:11 +0000 |
commit | f73f068967977545d4d60b36864475974dca2613 (patch) | |
tree | 25e0e0aad4faf12d9100173a8b5cb4866ec97cdf /sys/dev/asr | |
parent | 4ae371d305e8c60f2e534058d1727f819749b623 (diff) | |
download | FreeBSD-src-f73f068967977545d4d60b36864475974dca2613.zip FreeBSD-src-f73f068967977545d4d60b36864475974dca2613.tar.gz |
MFC r274819:
Prevent overflow issues in timeout processing
MFC r274852:
Fix build with asr driver
Sponsored by: Multiplay
Diffstat (limited to 'sys/dev/asr')
-rw-r--r-- | sys/dev/asr/asr.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/sys/dev/asr/asr.c b/sys/dev/asr/asr.c index 1e4f1a6..f603f10 100644 --- a/sys/dev/asr/asr.c +++ b/sys/dev/asr/asr.c @@ -384,22 +384,6 @@ typedef struct Asr_softc { static STAILQ_HEAD(, Asr_softc) Asr_softc_list = STAILQ_HEAD_INITIALIZER(Asr_softc_list); - -static __inline void -set_ccb_timeout_ch(union asr_ccb *ccb, struct callout_handle ch) -{ - ccb->ccb_h.sim_priv.entries[0].ptr = ch.callout; -} - -static __inline struct callout_handle -get_ccb_timeout_ch(union asr_ccb *ccb) -{ - struct callout_handle ch; - - ch.callout = ccb->ccb_h.sim_priv.entries[0].ptr; - return ch; -} - /* * Prototypes of the routines we have in this object. */ @@ -422,6 +406,25 @@ static void asr_action(struct cam_sim *sim, union ccb *ccb); static void asr_poll(struct cam_sim *sim); static int ASR_queue(Asr_softc_t *sc, PI2O_MESSAGE_FRAME Message); +static __inline void +set_ccb_timeout_ch(union asr_ccb *ccb) +{ + struct callout_handle ch; + + ch = timeout(asr_timeout, (caddr_t)ccb, + (int)((u_int64_t)(ccb->ccb_h.timeout) * (u_int32_t)hz / 1000)); + ccb->ccb_h.sim_priv.entries[0].ptr = ch.callout; +} + +static __inline struct callout_handle +get_ccb_timeout_ch(union asr_ccb *ccb) +{ + struct callout_handle ch; + + ch.callout = ccb->ccb_h.sim_priv.entries[0].ptr; + return ch; +} + /* * Here is the auto-probe structure used to nest our tests appropriately * during the startup phase of the operating system. @@ -812,8 +815,7 @@ ASR_ccbAdd(Asr_softc_t *sc, union asr_ccb *ccb) */ ccb->ccb_h.timeout = 6 * 60 * 1000; } - set_ccb_timeout_ch(ccb, timeout(asr_timeout, (caddr_t)ccb, - (ccb->ccb_h.timeout * hz) / 1000)); + set_ccb_timeout_ch(ccb); } splx(s); } /* ASR_ccbAdd */ @@ -1337,9 +1339,7 @@ asr_timeout(void *arg) cam_sim_unit(xpt_path_sim(ccb->ccb_h.path)), s); if (ASR_reset (sc) == ENXIO) { /* Try again later */ - set_ccb_timeout_ch(ccb, timeout(asr_timeout, - (caddr_t)ccb, - (ccb->ccb_h.timeout * hz) / 1000)); + set_ccb_timeout_ch(ccb); } return; } @@ -1353,9 +1353,7 @@ asr_timeout(void *arg) if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_CMD_TIMEOUT) { debug_asr_printf (" AGAIN\nreinitializing adapter\n"); if (ASR_reset (sc) == ENXIO) { - set_ccb_timeout_ch(ccb, timeout(asr_timeout, - (caddr_t)ccb, - (ccb->ccb_h.timeout * hz) / 1000)); + set_ccb_timeout_ch(ccb); } splx(s); return; @@ -1364,8 +1362,7 @@ asr_timeout(void *arg) /* If the BUS reset does not take, then an adapter reset is next! */ ccb->ccb_h.status &= ~CAM_STATUS_MASK; ccb->ccb_h.status |= CAM_CMD_TIMEOUT; - set_ccb_timeout_ch(ccb, timeout(asr_timeout, (caddr_t)ccb, - (ccb->ccb_h.timeout * hz) / 1000)); + set_ccb_timeout_ch(ccb); ASR_resetBus (sc, cam_sim_bus(xpt_path_sim(ccb->ccb_h.path))); xpt_async (AC_BUS_RESET, ccb->ccb_h.path, NULL); splx(s); |