From: brynet Date: Thu, 20 Apr 2023 10:49:57 +0000 (+0000) Subject: Move ring buffer allocation to before calling uhidev_open(), otherwise X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e165ecb1c0143f7b2068eaccc7d3c034250ac266;p=openbsd Move ring buffer allocation to before calling uhidev_open(), otherwise it might be NULL in uhid_intr. fixes "b_to_q: tty has no clist" panic hit by namn@ tested by thfr@ and namn@ ok anton@ --- diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 01b4a017a47..a036e3f1213 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.89 2022/07/02 08:50:42 visa Exp $ */ +/* $OpenBSD: uhid.c,v 1.90 2023/04/20 10:49:57 brynet Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -225,12 +225,17 @@ uhid_do_open(dev_t dev, int flag, int mode, struct proc *p) if (usbd_is_dying(sc->sc_hdev.sc_udev)) return (ENXIO); - error = uhidev_open(&sc->sc_hdev); - if (error) - return (error); + if (sc->sc_hdev.sc_state & UHIDEV_OPEN) + return (EBUSY); clalloc(&sc->sc_q, UHID_BSIZE, 0); + error = uhidev_open(&sc->sc_hdev); + if (error) { + clfree(&sc->sc_q); + return (error); + } + sc->sc_obuf = malloc(sc->sc_hdev.sc_osize, M_USBDEV, M_WAITOK); return (0);