NetBSD Problem Report #49927
From www@NetBSD.org Sun May 24 14:13:59 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 8A63BA654C
for <gnats-bugs@gnats.NetBSD.org>; Sun, 24 May 2015 14:13:59 +0000 (UTC)
Message-Id: <20150524141358.996DBA6555@mollari.NetBSD.org>
Date: Sun, 24 May 2015 14:13:58 +0000 (UTC)
From: rmh@freebsd.org
Reply-To: rmh@freebsd.org
To: gnats-bugs@NetBSD.org
Subject: [PATCH] Avoid division by zero in auich(4)
X-Send-Pr-Version: www-1.0
>Number: 49927
>Category: kern
>Synopsis: [PATCH] Avoid division by zero in auich(4)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 24 14:15:00 +0000 2015
>Closed-Date: Tue May 31 06:14:27 +0000 2016
>Last-Modified: Tue May 31 06:14:27 +0000 2016
>Originator: Robert Millan
>Release: HEAD
>Organization:
>Environment:
RUMP environment (on top of GNU/Linux host)
>Description:
Please consider the following fix for auich(4):
Avoid division by zero
As wait_us is calculated by polling an I/O register, it is possible
in certain environments (e.g. emulated hardware) that its value is
zero. That is, that the I/O poll loop exits in less than 1 μs.
The check avoids division by zero in such situation.
>How-To-Repeat:
>Fix:
diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c
index b2adad1..6a52800 100644
--- a/sys/dev/pci/auich.c
+++ b/sys/dev/pci/auich.c
@@ -1723,6 +1723,13 @@ auich_calibrate(struct auich_softc *sc)
rnd_add_data(NULL, &wait_us, sizeof(wait_us), 1);
+ /* avoid division by 0 below */
+ if (wait_us == 0) {
+ printf("%s: abnormal zero delay during calibration\n",
+ device_xname(sc->sc_dev));
+ return;
+ }
+
actual_48k_rate = (bytes * UINT64_C(250000)) / wait_us;
if (actual_48k_rate < 50000)
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49927 CVS commit: src/sys/dev/pci
Date: Sun, 24 May 2015 10:56:57 -0400
Module Name: src
Committed By: christos
Date: Sun May 24 14:56:57 UTC 2015
Modified Files:
src/sys/dev/pci: auich.c
Log Message:
PR/49927: Robert Millan: Avoid zerodivide on emulated hardware.
To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/dev/pci/auich.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 06:14:27 +0000
State-Changed-Why:
This was fixed by Christos@ on May 24 14:56:57 UTC 2015
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.