ihidev(4): Prohibit closing an unopened ihidev.
This commit is contained in:
parent
0aca25b218
commit
3b602431c5
|
@ -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 $ */
|
/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__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 <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -919,10 +919,10 @@ ihidev_close(struct ihidev *scd)
|
||||||
|
|
||||||
mutex_enter(&sc->sc_lock);
|
mutex_enter(&sc->sc_lock);
|
||||||
|
|
||||||
/* XXX make this an assertion */
|
KASSERTMSG(scd->sc_state & IHIDEV_OPEN,
|
||||||
if (!(scd->sc_state & IHIDEV_OPEN))
|
"%s: closing %s when not open",
|
||||||
goto out;
|
device_xname(scd->sc_idev),
|
||||||
|
device_xname(sc->sc_dev));
|
||||||
scd->sc_state &= ~IHIDEV_OPEN;
|
scd->sc_state &= ~IHIDEV_OPEN;
|
||||||
|
|
||||||
if (--sc->sc_refcnt)
|
if (--sc->sc_refcnt)
|
||||||
|
|
Loading…
Reference in New Issue