Module Name: src
Committed By: martin
Date: Fri Jun 22 15:48:57 UTC 2018
Modified Files:
src/sys/dev/i2c: dbcool.c
Log Message:
Add a kernel panic when we matched but can not handle a string - better
die explicitly instead of crashing a few lines later with strange NULL
derefs.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/i2c/dbcool.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/dbcool.c
diff -u src/sys/dev/i2c/dbcool.c:1.50 src/sys/dev/i2c/dbcool.c:1.51
--- src/sys/dev/i2c/dbcool.c:1.50 Mon Jun 18 17:07:07 2018
+++ src/sys/dev/i2c/dbcool.c Fri Jun 22 15:48:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dbcool.c,v 1.50 2018/06/18 17:07:07 thorpej Exp $ */
+/* $NetBSD: dbcool.c,v 1.51 2018/06/22 15:48:57 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.50 2018/06/18 17:07:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.51 2018/06/22 15:48:57 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -779,9 +779,11 @@ dbcool_attach(device_t parent, device_t
sc->sc_dc.dc_chip = NULL;
sc->sc_dc.dc_readreg = dbcool_readreg;
sc->sc_dc.dc_writereg = dbcool_writereg;
- (void)dbcool_chip_ident(&sc->sc_dc);
sc->sc_dev = self;
+ if (dbcool_chip_ident(&sc->sc_dc) < 0 || sc->sc_dc.dc_chip == NULL)
+ panic("could not identify chip at addr %d", args->ia_addr);
+
aprint_naive("\n");
aprint_normal("\n");