NetBSD Problem Report #12471

Received: (qmail 28433 invoked from network); 25 Mar 2001 16:47:36 -0000
Message-Id: <200103251647.f2PGlGX07134@capybara.yamanet>
Date: Mon, 26 Mar 2001 01:47:16 +0900 (JST)
From: takashi.yamamoto@bigfoot.com
Reply-To: takashi.yamamoto@bigfoot.com
To: gnats-bugs@gnats.netbsd.org
Subject: adv driver can't handle big timeout value
X-Send-Pr-Version: 3.95

>Number:         12471
>Category:       kern
>Synopsis:       adv driver can't handle big timeout value
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 25 16:48:00 +0000 2001
>Closed-Date:    Tue Mar 27 17:24:41 +0000 2001
>Last-Modified:  Tue Mar 27 17:24:41 +0000 2001
>Originator:     YAMAMOTO Takashi
>Release:        NetBSD-current
>Organization:

---
YAMAMOTO Takashi<takashi.yamamoto@bigfoot.com>
>Environment:
System: NetBSD capybara 1.5T NetBSD 1.5T (stg) #169: Sat Mar 24 11:46:48 JST 2001 takashi@capybara:/usr/src/sys/arch/i386/compile/stg i386
Architecture: i386
Machine: i386
>Description:
	overflow is occur when driver translates msec value to ticks.
>How-To-Repeat:
	initiate scsi cmd with big timeout value.
	ex. scsictl /dev/sd0 format
>Fix:
	following is patch.

Index: adv.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/adv.c,v
retrieving revision 1.22
diff -u -u -r1.22 adv.c
--- adv.c	2001/03/08 06:49:49	1.22
+++ adv.c	2001/03/25 16:12:47
@@ -69,6 +69,28 @@

 /* #define ASC_DEBUG */

+int inline msec_to_tick(u_long);
+/* XXX this should not be here? */
+int inline msec_to_tick(u_long ms)
+{
+	/*
+	 * convert msec to tick.
+	 *
+	 * this function is used for callout_reset,
+	 * so return value is int.
+	 */
+	int tick;
+
+	if (ms / 1000 >= INT_MAX / hz) {
+		tick = INT_MAX;
+	}
+	else {
+		tick = ms * hz / 1000;
+	}
+
+	return tick;
+}
+
 /******************************************************************************/


@@ -375,7 +397,7 @@

 		if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
 			callout_reset(&ccb->xs->xs_callout,
-			    (ccb->timeout * hz) / 1000,
+			    msec_to_tick(ccb->timeout * hz),
 			    adv_timeout, ccb);
 	}
 }
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bouyer 
State-Changed-When: Tue Mar 27 09:21:52 PST 2001 
State-Changed-Why:  
Fixed, although differently: a cast to u_int64_t is enouth. 
Thanks ! 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.