Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb auvitek(4): Fix i2c detach if attach failed.
details: https://anonhg.NetBSD.org/src/rev/e613360206ae
branches: trunk
changeset: 363476:e613360206ae
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 13 12:49:36 2022 +0000
description:
auvitek(4): Fix i2c detach if attach failed.
While here, use config_detach_children.
Reported-by: syzbot+bf05898af6a53cb3b262%syzkaller.appspotmail.com@localhost
diffstat:
sys/dev/usb/auvitek.c | 16 ++++++++++++++--
sys/dev/usb/auvitek_audio.c | 8 ++------
sys/dev/usb/auvitek_dtv.c | 8 ++------
sys/dev/usb/auvitek_i2c.c | 14 +++++++++-----
sys/dev/usb/auvitek_video.c | 8 ++------
sys/dev/usb/auvitekvar.h | 3 ++-
6 files changed, 31 insertions(+), 26 deletions(-)
diffs (192 lines):
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitek.c
--- a/sys/dev/usb/auvitek.c Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitek.c Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek.c,v 1.12 2020/03/14 02:35:33 christos Exp $ */
+/* $NetBSD: auvitek.c,v 1.13 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.12 2020/03/14 02:35:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.13 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -260,9 +260,21 @@
auvitek_detach(device_t self, int flags)
{
struct auvitek_softc *sc = device_private(self);
+ int error;
sc->sc_dying = 1;
+ error = config_detach_children(self, flags);
+ if (error) {
+ /*
+ * XXX Should ask autoconf to block open with
+ * .d_cfdriver until we're done, instead of setting
+ * this and then rolling it back.
+ */
+ sc->sc_dying = 0;
+ return error;
+ }
+
pmf_device_deregister(self);
auvitek_dtv_detach(sc, flags);
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitek_audio.c
--- a/sys/dev/usb/auvitek_audio.c Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitek_audio.c Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_audio.c,v 1.5 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_audio.c,v 1.6 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_audio.c,v 1.5 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_audio.c,v 1.6 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -112,10 +112,6 @@
int
auvitek_audio_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_audiodev != NULL) {
- config_detach(sc->sc_audiodev, flags);
- sc->sc_audiodev = NULL;
- }
return 0;
}
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitek_dtv.c
--- a/sys/dev/usb/auvitek_dtv.c Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitek_dtv.c Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.9 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.10 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.9 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.10 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,10 +98,6 @@
int
auvitek_dtv_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_dtvdev != NULL) {
- config_detach(sc->sc_dtvdev, flags);
- sc->sc_dtvdev = NULL;
- }
return 0;
}
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitek_i2c.c
--- a/sys/dev/usb/auvitek_i2c.c Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitek_i2c.c Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_i2c.c,v 1.7 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_i2c.c,v 1.8 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_i2c.c,v 1.7 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_i2c.c,v 1.8 2022/03/13 12:49:36 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -71,22 +71,26 @@
int
auvitek_i2c_attach(struct auvitek_softc *sc)
{
+
iic_tag_init(&sc->sc_i2c);
sc->sc_i2c.ic_cookie = sc;
sc->sc_i2c.ic_exec = auvitek_i2c_exec;
auvitek_i2c_rescan(sc, NULL, NULL);
+ sc->sc_i2c_attached = true;
+
return 0;
}
int
auvitek_i2c_detach(struct auvitek_softc *sc, int flags)
{
- iic_tag_fini(&sc->sc_i2c);
- if (sc->sc_i2cdev)
- config_detach(sc->sc_i2cdev, flags);
+ if (!sc->sc_i2c_attached)
+ return 0;
+
+ iic_tag_fini(&sc->sc_i2c);
return 0;
}
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitek_video.c
--- a/sys/dev/usb/auvitek_video.c Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitek_video.c Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_video.c,v 1.10 2022/03/03 06:23:25 riastradh Exp $ */
+/* $NetBSD: auvitek_video.c,v 1.11 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.10 2022/03/03 06:23:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.11 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -140,10 +140,6 @@
int
auvitek_video_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_videodev != NULL) {
- config_detach(sc->sc_videodev, flags);
- sc->sc_videodev = NULL;
- }
return 0;
}
diff -r be13e56854e0 -r e613360206ae sys/dev/usb/auvitekvar.h
--- a/sys/dev/usb/auvitekvar.h Sun Mar 13 12:30:47 2022 +0000
+++ b/sys/dev/usb/auvitekvar.h Sun Mar 13 12:49:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitekvar.h,v 1.9 2016/04/23 10:15:31 skrll Exp $ */
+/* $NetBSD: auvitekvar.h,v 1.10 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -102,6 +102,7 @@
device_t sc_videodev, sc_dtvdev, sc_audiodev, sc_i2cdev;
struct i2c_controller sc_i2c;
kmutex_t sc_i2c_lock;
+ bool sc_i2c_attached;
struct usbd_device *sc_udev;
int sc_uport;
Home |
Main Index |
Thread Index |
Old Index