From 2e75e5a699862007700744b5693e14a7041660f8 Mon Sep 17 00:00:00 2001 From: macallan Date: Thu, 1 Apr 2010 05:26:48 +0000 Subject: [PATCH] don't divide by zero. ever. --- sys/dev/i2c/dbcool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/i2c/dbcool.c b/sys/dev/i2c/dbcool.c index c0509a2fa0e3..bec4acaef4ed 100644 --- a/sys/dev/i2c/dbcool.c +++ b/sys/dev/i2c/dbcool.c @@ -1,4 +1,4 @@ -/* $NetBSD: dbcool.c,v 1.22 2010/04/01 04:29:35 macallan Exp $ */ +/* $NetBSD: dbcool.c,v 1.23 2010/04/01 05:26:48 macallan Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.22 2010/04/01 04:29:35 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.23 2010/04/01 05:26:48 macallan Exp $"); #include #include @@ -922,7 +922,8 @@ dbcool_read_rpm(struct dbcool_softc *sc, uint8_t reg) if (rpm == 0xffff) return 0; /* 0xffff indicates stalled/failed fan */ - return (sc->sc_dc.dc_chip->rpm_dividend / rpm); + /* don't divide by zero */ + return (rpm == 0)? 0 : (sc->sc_dc.dc_chip->rpm_dividend / rpm); } /* Provide chip's supply voltage, in microvolts */