From 3b602431c5f9f4b69bb4d2705943f43b60985042 Mon Sep 17 00:00:00 2001 From: riastradh Date: Fri, 14 Jan 2022 22:28:59 +0000 Subject: [PATCH] ihidev(4): Prohibit closing an unopened ihidev. --- sys/dev/i2c/ihidev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c index 2e59c5ca7228..f16a541956bb 100644 --- a/sys/dev/i2c/ihidev.c +++ b/sys/dev/i2c/ihidev.c @@ -1,4 +1,4 @@ -/* $NetBSD: ihidev.c,v 1.25 2022/01/14 22:28:50 riastradh Exp $ */ +/* $NetBSD: ihidev.c,v 1.26 2022/01/14 22:28:59 riastradh Exp $ */ /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */ /*- @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.25 2022/01/14 22:28:50 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.26 2022/01/14 22:28:59 riastradh Exp $"); #include #include @@ -919,10 +919,10 @@ ihidev_close(struct ihidev *scd) mutex_enter(&sc->sc_lock); - /* XXX make this an assertion */ - if (!(scd->sc_state & IHIDEV_OPEN)) - goto out; - + KASSERTMSG(scd->sc_state & IHIDEV_OPEN, + "%s: closing %s when not open", + device_xname(scd->sc_idev), + device_xname(sc->sc_dev)); scd->sc_state &= ~IHIDEV_OPEN; if (--sc->sc_refcnt)