From: mpi Date: Wed, 7 May 2014 08:17:21 +0000 (+0000) Subject: Make sure to call uhidev_close() upon detach for every HID driver calling X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9dcdfc618265057d8bd63522c536e137b6d02a6b;p=openbsd Make sure to call uhidev_close() upon detach for every HID driver calling uhidev_open() at attach time. This plugs up to 3 xfer leaks and a buffer one. ok yuo@ --- diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index 10ee32d5f18..ca2beebe5d9 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucycom.c,v 1.26 2014/04/15 09:14:27 mpi Exp $ */ +/* $OpenBSD: ucycom.c,v 1.27 2014/05/07 08:17:21 mpi Exp $ */ /* $NetBSD: ucycom.c,v 1.3 2005/08/05 07:27:47 skrll Exp $ */ /* @@ -582,6 +582,10 @@ ucycom_detach(struct device *self, int flags) config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } + + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + return (0); } diff --git a/sys/dev/usb/uoaklux.c b/sys/dev/usb/uoaklux.c index ad0761b2367..9a3b2403cc4 100644 --- a/sys/dev/usb/uoaklux.c +++ b/sys/dev/usb/uoaklux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoaklux.c,v 1.7 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uoaklux.c,v 1.8 2014/05/07 08:17:21 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO @@ -208,6 +208,9 @@ uoaklux_detach(struct device *self, int flags) if (sc->sc_sensortask != NULL) sensor_task_unregister(sc->sc_sensortask); + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + if (scc->sc_ibuf != NULL) { free(scc->sc_ibuf, M_USBDEV); scc->sc_ibuf = NULL; diff --git a/sys/dev/usb/uoakrh.c b/sys/dev/usb/uoakrh.c index 580fe3002aa..0540e2d3a13 100644 --- a/sys/dev/usb/uoakrh.c +++ b/sys/dev/usb/uoakrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakrh.c,v 1.8 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uoakrh.c,v 1.9 2014/05/07 08:17:21 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO @@ -224,6 +224,9 @@ uoakrh_detach(struct device *self, int flags) if (sc->sc_sensortask != NULL) sensor_task_unregister(sc->sc_sensortask); + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + if (scc->sc_ibuf != NULL) { free(scc->sc_ibuf, M_USBDEV); scc->sc_ibuf = NULL; diff --git a/sys/dev/usb/uoakv.c b/sys/dev/usb/uoakv.c index aaa43f61df3..40093d57e5f 100644 --- a/sys/dev/usb/uoakv.c +++ b/sys/dev/usb/uoakv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakv.c,v 1.7 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uoakv.c,v 1.8 2014/05/07 08:17:21 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO @@ -212,6 +212,9 @@ uoakv_detach(struct device *self, int flags) if (sc->sc_sensortask != NULL) sensor_task_unregister(sc->sc_sensortask); + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + if (scc->sc_ibuf != NULL) { free(scc->sc_ibuf, M_USBDEV); scc->sc_ibuf = NULL; diff --git a/sys/dev/usb/utrh.c b/sys/dev/usb/utrh.c index 17eb6a87665..451734de700 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.14 2014/04/15 09:14:27 mpi Exp $ */ +/* $OpenBSD: utrh.c,v 1.15 2014/05/07 08:17:21 mpi Exp $ */ /* * Copyright (c) 2009 Yojiro UO @@ -175,6 +175,9 @@ utrh_detach(struct device *self, int flags) sensor_task_unregister(sc->sc_sensortask); } + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + if (sc->sc_ibuf != NULL) { free(sc->sc_ibuf, M_USBDEV); sc->sc_ibuf = NULL; diff --git a/sys/dev/usb/utwitch.c b/sys/dev/usb/utwitch.c index 69dd6359f13..2f7c0c0dcc4 100644 --- a/sys/dev/usb/utwitch.c +++ b/sys/dev/usb/utwitch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utwitch.c,v 1.11 2014/04/15 09:14:27 mpi Exp $ */ +/* $OpenBSD: utwitch.c,v 1.12 2014/05/07 08:17:21 mpi Exp $ */ /* * Copyright (c) 2010 Yojiro UO @@ -189,6 +189,9 @@ utwitch_detach(struct device *self, int flags) if (sc->sc_sensortask != NULL) sensor_task_unregister(sc->sc_sensortask); + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + uhidev_close(&sc->sc_hdev); + if (sc->sc_ibuf != NULL) { free(sc->sc_ibuf, M_USBDEV); sc->sc_ibuf = NULL;