Re: CVS commit: src/sys/dev/usb
On Wed, 27 May 2020, Taylor R Campbell wrote: Not really, because we just need to know whether usb_once_init has been run. OK, great! Now, should we use something other than RUN_ONCE, which can both set up and tear down? Sure, that might be better in principle, but there probably aren't that many systems that have hotpluggable USB in which you might unplug _all_ of the USBs and where you really want to save the cost of a couple kernel threads. So not likely worth much effort. I was thinking more in terms of someone using drvctl(8) to cause the detach. But yeah, it's not a very common use-case, so as long as we don't _need_ the decrement, it's not worth losing any sleep. :) Thanks for the reply. ++--+---+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com | | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | ++--+---+
Re: CVS commit: src/sys/dev/usb
> Date: Wed, 27 May 2020 05:28:41 -0700 (PDT) > From: Paul Goyette > > Do you also need to decrement the number of busses when one is > detached? Not really, because we just need to know whether usb_once_init has been run. Now, should we use something other than RUN_ONCE, which can both set up and tear down? Sure, that might be better in principle, but there probably aren't that many systems that have hotpluggable USB in which you might unplug _all_ of the USBs and where you really want to save the cost of a couple kernel threads. So not likely worth much effort.
Re: CVS commit: src/sys/dev/usb
Do you also need to decrement the number of busses when one is detached? On Wed, 27 May 2020, Nick Hudson wrote: Module Name:src Committed By: skrll Date: Wed May 27 07:17:45 UTC 2020 Modified Files: src/sys/dev/usb: usb.c Log Message: Don't allow open of /dev/usb if there are no attached busses. PR kern/55303 mutex_vector_enter,512: uninitialized lock To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/dev/usb/usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. !DSPAM:5ece145a266021866921056! ++--+---+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com | | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | ++--+---+
Re: CVS commit: src/sys/dev/usb
On Thu, Apr 2, 2020 at 8:37 PM Nick Hudson wrote: > > Module Name:src > Committed By: skrll > Date: Thu Apr 2 11:37:23 UTC 2020 > > Modified Files: > src/sys/dev/usb: xhci.c xhcivar.h > > Log Message: > Reduce the memory footprint by allocating a ring per endpoint/pipe on > pipe open. > > From sc.dying on tech-kern Thank you for applying the patch.
Re: CVS commit: src/sys/dev/usb
Le 23/03/2020 à 04:07, Roy Marples a écrit : > On 22/03/2020 08:30, Maxime Villard wrote: >> Overall "From OpenBSD" is a redflag for buggy and vulnerable code.. > > We should be above this, no software is perfect, not even ours. > > Roy You seem to be confusing one-off defects and structural deficiencies. That a plane crashes because of one slightly malformed screw, is a one-off defect. Yes, sh*t happens, that's statistical, and in the order of things. That a plane crashes because pilots have trained on a faulty simulator, are faced with incomplete emergency manuals, that don't document the faulty flight computer about to bring the plane down, itself installed to work around the plane's faulty airframe, is a big redflag for structural deficiencies. In that you could as well fix the simulator, fix the manuals, fix the computer, fix the airframe, that there would still be a consistent way for the plane to crash, because it is just so structurally deficient, that no one could honestly put any kind of trust in it. Damn, I love this analogy. Anyway, to come back to the point, I have come to notice that several organizations (very big ones sometimes...) produce code that is very close to structurally deficient, and that's a source of concern for our QA when that code gets imported. In the case of OpenBSD I don't know if it is recent or if it has always been like this, I would tend to think the latter. So yeah big redflag when I see a "from ...", that's an indication that the area needs attention. In all cases, these specific issues with if_umb are not urgent, because the driver is disabled by default in NetBSD. Interesting technical challenge though, if someone is interested! Maxime
Re: CVS commit: src/sys/dev/usb
On 22/03/2020 08:30, Maxime Villard wrote: Overall "From OpenBSD" is a redflag for buggy and vulnerable code.. We should be above this, no software is perfect, not even ours. Roy
Re: CVS commit: src/sys/dev/usb
Le 19/03/2020 à 08:49, Pierre Pronchery a écrit : > Module Name: src > Committed By: khorben > Date: Thu Mar 19 07:49:29 UTC 2020 > > Modified Files: > src/sys/dev/usb: if_umb.c > > Log Message: > When there is no network around the state timeout fires over and over again. > Change the printf into a log and only under IFF_DEBUG to reduce dmesg spam. > Loudly requested by beck@ OK deraadt@ FWIW, there is a number of potentially exploitable bugs in this driver, and they have been in my todo list for three months. Eg, follow umb_decode_response(), there are integer overflows that can trigger actual buffer overflows. Would you be interested in fixing the vulns? > From OpenBSD. Overall "From OpenBSD" is a redflag for buggy and vulnerable code.. Maxime
Re: CVS commit: src/sys/dev/usb
On 18/03/2020 11:33, Robert Elz wrote: > Module Name: src > Committed By: kre > Date: Wed Mar 18 11:33:32 UTC 2020 > > Modified Files: > src/sys/dev/usb: if_aue.c > > Log Message: > This was still not correct,. USB_DEBUG is what mattered, not AUE_DEBUG, > the two are orthogonal. They're not orthogonal... http://src.illumos.org/source/xref/netbsd-src/sys/dev/usb/files.usb#25 25 defflag opt_usb.h AUE_DEBUG: USB_DEBUG Just saying. Nick
Re: CVS commit: src/sys/dev/usb
Date:Tue, 17 Mar 2020 22:58:24 -0400 From:"Christos Zoulas" Message-ID: <20200318025824.93b28f...@cvs.netbsd.org> | Log Message: | define un (pointed out by kre@) The reason I didn't suggest that change, is that now un is unused when USB_DEBUG is not defined. At the very least it would need a __debugused or whatever that #define for the relevant attribute is. But for just a single use, it seemed simpler just to use the value used to init the var that is (now) only used the once. kre
Re: CVS commit: src/sys/dev/usb
In article <20200314143238.gr5...@pony.stderr.spb.ru>, Valery Ushakov wrote: >How is is affected by the decision to change (or not) 0x%x to %#x? > This was in response to the statement: ... with a bit of patience might have been less drastic and as effective. christos
Re: CVS commit: src/sys/dev/usb
On Sat, Mar 14, 2020 at 10:27:27 -0400, Christos Zoulas wrote: > > I don't belive that "if". It's like claiming you got rid of a stain > > on a wallpaper after you demolish a wall (not load-bearing, > > fortunately) and have to put it back and put new wallpaper. :) Get rid > > of the stain, sure; but may be looking closely with a bit of patience > > might have been less drastic and as effective. > > To fix the kernhist ones I looked with a lot of patience and even then, > I missed quite a few ones (the ones in the final commit). It is really > difficult to find them, specially because the DPRINTF macros are > used sometimes for regular debugging and other times for kernhist. > In the end I had to add a fake printf function in kernhist.h like below, > and then filter out the error messages about too many arguments for > format. > > christos > > --- kernhist.h 2020-03-13 23:03:13.973939910 -0400 > +++ kernhist.h.orig 2020-03-13 22:59:37.237495925 -0400 > @@ -207,6 +207,11 @@ > #define KERNHIST_PRINTNOW(E) /* nothing */ > #endif > > +// Just for format checking > +static __inline __printflike(1, 2) void > +__kernhist_printf(const char *fmt __unused, ...) { > +} > + > #define KERNHIST_LOG(NAME,FMT,A,B,C,D) \ > do { \ > unsigned int _i_, _j_; \ > @@ -227,6 +232,7 @@ > _e_->v[1] = (uintmax_t)(B); \ > _e_->v[2] = (uintmax_t)(C); \ > _e_->v[3] = (uintmax_t)(D); \ > + __kernhist_printf(FMT, _e_->v[0], _e_->v[1], _e_->v[2], _e_->v[3]); \ > KERNHIST_PRINTNOW(_e_); \ > } while (/*CONSTCOND*/ 0) How is is affected by the decision to change (or not) 0x%x to %#x? -uwe
Re: CVS commit: src/sys/dev/usb
> I don't belive that "if". It's like claiming you got rid of a stain > on a wallpaper after you demolish a wall (not load-bearing, > fortunately) and have to put it back and put new wallpaper. :) Get rid > of the stain, sure; but may be looking closely with a bit of patience > might have been less drastic and as effective. To fix the kernhist ones I looked with a lot of patience and even then, I missed quite a few ones (the ones in the final commit). It is really difficult to find them, specially because the DPRINTF macros are used sometimes for regular debugging and other times for kernhist. In the end I had to add a fake printf function in kernhist.h like below, and then filter out the error messages about too many arguments for format. christos --- kernhist.h 2020-03-13 23:03:13.973939910 -0400 +++ kernhist.h.orig 2020-03-13 22:59:37.237495925 -0400 @@ -207,6 +207,11 @@ #define KERNHIST_PRINTNOW(E) /* nothing */ #endif +// Just for format checking +static __inline __printflike(1, 2) void +__kernhist_printf(const char *fmt __unused, ...) { +} + #define KERNHIST_LOG(NAME,FMT,A,B,C,D) \ do { \ unsigned int _i_, _j_; \ @@ -227,6 +232,7 @@ _e_->v[1] = (uintmax_t)(B); \ _e_->v[2] = (uintmax_t)(C); \ _e_->v[3] = (uintmax_t)(D); \ + __kernhist_printf(FMT, _e_->v[0], _e_->v[1], _e_->v[2], _e_->v[3]); \ KERNHIST_PRINTNOW(_e_); \ } while (/*CONSTCOND*/ 0) signature.asc Description: Message signed with OpenPGP
Re: CVS commit: src/sys/dev/usb
On Sat, Mar 14, 2020 at 09:57:36 -0400, Christos Zoulas wrote: > > Even for the ones without the widths specified. E.g. I personally > > prefer zero printed as 0x0, not as 0, so I assume that when people > > choose either one that reflects their preference. Why mess with it? > > It's all so unnecessary. > > Yes, now we are discussing cosmetics (if 0 should be printed as 0 or > 0x0 mostly in debugging messages), since this is the only change > remaining. > > In retrospect, perhaps I should have left it alone, It would have been better to just leave them the hell alone as they are to begin with. This is, I think, the third time in recent memory when people try to "fix" 0x%x -> %#x and each time it goes wrong. We should have learned from that. > but now aside the cosmetics part, we are strictly better off because > all the formats have been fixed Which is true but non sequitur. > (including the 2 ones which we would not have found if I did not > make the %# change). I don't belive that "if". It's like claiming you got rid of a stain on a wallpaper after you demolish a wall (not load-bearing, fortunately) and have to put it back and put new wallpaper. :) Get rid of the stain, sure; but may be looking closely with a bit of patience might have been less drastic and as effective. -uwe
Re: CVS commit: src/sys/dev/usb
> Even for the ones without the widths specified. E.g. I personally > prefer zero printed as 0x0, not as 0, so I assume that when people > choose either one that reflects their preference. Why mess with it? > It's all so unnecessary. Yes, now we are discussing cosmetics (if 0 should be printed as 0 or 0x0 mostly in debugging messages), since this is the only change remaining. In retrospect, perhaps I should have left it alone, but now aside the cosmetics part, we are strictly better off because all the formats have been fixed (including the 2 ones which we would not have found if I did not make the %# change). christos signature.asc Description: Message signed with OpenPGP
re: CVS commit: src/sys/dev/usb
> As I wrote in a follow up email, it changes formatting b/c you didn't > change field widths and IMO using %# with a field width is mostly > trouble to begin with. It's not the first time someone tries to do > this without actually understanding the consequences of the change. > Please, can we assume that when people write either 0x%x or %#x they > most likely actaully mean it for whatever reason and that they want > that specific output format, and it's just rude to change that, > especially when you do so incorrectly. i've come to agree that %# is dangerous in general to save one character. not only does it have the width issue you've mentioned, but it also emits "0" instead of "0x0" for the zero case, which i find surprising. christos, thanks for the backout. .mrg.
Re: CVS commit: src/sys/dev/usb
On Fri, Mar 13, 2020 at 22:26:05 -0400, Christos Zoulas wrote: > > On Mar 13, 2020, at 10:25 PM, Valery Ushakov wrote: > > > > As I wrote in a follow up email, it changes formatting b/c you didn't > > change field widths and IMO using %# with a field width is mostly > > trouble to begin with. It's not the first time someone tries to do > > this without actually understanding the consequences of the change. > > Please, can we assume that when people write either 0x%x or %#x they > > most likely actaully mean it for whatever reason and that they want > > that specific output format, and it's just rude to change that, > > especially when you do so incorrectly. > > I am reverting the fixed width ones, hold on. Even for the ones without the widths specified. E.g. I personally prefer zero printed as 0x0, not as 0, so I assume that when people choose either one that reflects their preference. Why mess with it? It's all so unnecessary. -uwe
Re: CVS commit: src/sys/dev/usb
> On Mar 13, 2020, at 10:25 PM, Valery Ushakov wrote: > > As I wrote in a follow up email, it changes formatting b/c you didn't > change field widths and IMO using %# with a field width is mostly > trouble to begin with. It's not the first time someone tries to do > this without actually understanding the consequences of the change. > Please, can we assume that when people write either 0x%x or %#x they > most likely actaully mean it for whatever reason and that they want > that specific output format, and it's just rude to change that, > especially when you do so incorrectly. I am reverting the fixed width ones, hold on. christos signature.asc Description: Message signed with OpenPGP
Re: CVS commit: src/sys/dev/usb
On Fri, Mar 13, 2020 at 22:15:31 -0400, Christos Zoulas wrote: > > This was not a part of the PR and is completely cosmetic (surely it > > supports plain %x if it does support %#x). Why was this necessary? > > (I know I would be quite miffed if someone made a change like that to > > my code). > > Yes, that %x formatting change was not part of the PR, but I only > changed 0x%x not plain %x. I did it because as I was fixing the > 0x%x in the log, I started changing them to %#jx so I did it > globally in that directory for consistency. It found two formats > that were 0x%hu... > > So one can view it as a format consistency checker(not just cosmetic). As I wrote in a follow up email, it changes formatting b/c you didn't change field widths and IMO using %# with a field width is mostly trouble to begin with. It's not the first time someone tries to do this without actually understanding the consequences of the change. Please, can we assume that when people write either 0x%x or %#x they most likely actaully mean it for whatever reason and that they want that specific output format, and it's just rude to change that, especially when you do so incorrectly. -uwe
Re: CVS commit: src/sys/dev/usb
> This was not a part of the PR and is completely cosmetic (surely it > supports plain %x if it does support %#x). Why was this necessary? > (I know I would be quite miffed if someone made a change like that to > my code). Yes, that %x formatting change was not part of the PR, but I only changed 0x%x not plain %x. I did it because as I was fixing the 0x%x in the log, I started changing them to %#jx so I did it globally in that directory for consistency. It found two formats that were 0x%hu... So one can view it as a format consistency checker(not just cosmetic). christos signature.asc Description: Message signed with OpenPGP
Re: CVS commit: src/sys/dev/usb
On Fri, Mar 13, 2020 at 17:09:14 -0700, Paul Goyette wrote: > On Sat, 14 Mar 2020, Valery Ushakov wrote: > > > On Fri, Mar 13, 2020 at 14:17:42 -0400, Christos Zoulas wrote: > > > > > Log Message: > > > PR/55068: sc.dying: Fix printf formats: > > [...] > > > - 0x% -> %# > > > > This was not a part of the PR and is completely cosmetic (surely it > > supports plain %x if it does support %#x). Why was this necessary? > > (I know I would be quite miffed if someone made a change like that to > > my code). > > Plain %x - no :( > > In order to enable sysctl-transport to userland, all the args need to > be promoted to %jx, and the format strings need to ensure that they > consume that size. Random sample from the diff: - printf("%s: expect 0xe6!! (0x%x)\n", device_xname(sc->sc_dev), + printf("%s: expect 0xe6!! (%#x)\n", device_xname(sc->sc_dev), Actually, looking close I see diffs like - DPRINTFN(MD_ROOT, "wValue=0x%04jx", value, 0, 0, 0); + DPRINTFN(MD_ROOT, "wValue=%#04jx", value, 0, 0, 0); that are plain wrong as %#x counts the 0x prefix towards the field width. $ printf '0x%02x %#02x\n' 1 1 0x01 0x1 $ printf '0x%08x 0x%08x\n%#08x %#08x\n' 0 1 0 1 0x 0x0001 0x01 So, as far as I can tell, these %# changes don't fix all the argument size issues, break some output formatting and violate preference of the original author. Did I miss something else? -uwe
Re: CVS commit: src/sys/dev/usb
On Sat, 14 Mar 2020, Valery Ushakov wrote: On Fri, Mar 13, 2020 at 14:17:42 -0400, Christos Zoulas wrote: Log Message: PR/55068: sc.dying: Fix printf formats: [...] - 0x% -> %# This was not a part of the PR and is completely cosmetic (surely it supports plain %x if it does support %#x). Why was this necessary? (I know I would be quite miffed if someone made a change like that to my code). Plain %x - no :( In order to enable sysctl-transport to userland, all the args need to be promoted to %jx, and the format strings need to ensure that they consume that size. ++--+---+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com | | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | ++--+---+
Re: CVS commit: src/sys/dev/usb
On Fri, Mar 13, 2020 at 14:17:42 -0400, Christos Zoulas wrote: > Log Message: > PR/55068: sc.dying: Fix printf formats: [...] > - 0x% -> %# This was not a part of the PR and is completely cosmetic (surely it supports plain %x if it does support %#x). Why was this necessary? (I know I would be quite miffed if someone made a change like that to my code). -uwe
Re: CVS commit: src/sys/dev/usb
On Tue, Dec 03, 2019 at 05:01:45AM +, Taylor R Campbell wrote: > Module Name: src > Committed By: riastradh > Date: Tue Dec 3 05:01:45 UTC 2019 > > Modified Files: > src/sys/dev/usb: usbnet.c > > Log Message: > Fix order of nulling un->un_pri->unp_ec.ec_mii. > > Can't null it until after if_detach prevents further use. > > While here, fix conditionals in usbnet_tick_task to use the unp_dying > flag, not the nullness of mii (or of ifp, which never null because > it's an embedded member). > > > To generate a diff of this commit: > cvs rdiff -u -r1.30 -r1.31 src/sys/dev/usb/usbnet.c This breaks urndis(4). See http://gnats.netbsd.org/54762 The following diff restores it to work. Index: usbnet.c === RCS file: /cvsroot/src/sys/dev/usb/usbnet.c,v retrieving revision 1.32 diff -u -r1.32 usbnet.c --- usbnet.c3 Dec 2019 05:01:58 - 1.32 +++ usbnet.c14 Dec 2019 14:34:45 - @@ -1197,9 +1197,11 @@ usbnet_watchdog(ifp); DPRINTFN(8, "mii %jx ifp %jx", (uintptr_t)mii, (uintptr_t)ifp, 0, 0); - mii_tick(mii); - if (!unp->unp_link) - (*mii->mii_statchg)(ifp); + if (mii) { + mii_tick(mii); + if (!unp->unp_link) + (*mii->mii_statchg)(ifp); + } /* Call driver if requested. */ uno_tick(un);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Fri Nov 29 14:15:42 UTC 2019 Modified Files: src/sys/dev/usb: ohci.c Log Message: Preserve the toggleCarry bit in the Endpoint Descriptor in ohci_abort_xfer(). Fixes the OHCI part of PR kern/50278. To generate a diff of this commit: cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Fri Nov 29 14:15:42 UTC 2019 Modified Files: src/sys/dev/usb: ohci.c Log Message: Preserve the toggleCarry bit in the Endpoint Descriptor in ohci_abort_xfer(). Fixes the OHCI part of PR kern/50278. To generate a diff of this commit: cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.291 src/sys/dev/usb/ohci.c:1.292 --- src/sys/dev/usb/ohci.c:1.291 Fri Nov 29 14:13:04 2019 +++ src/sys/dev/usb/ohci.c Fri Nov 29 14:15:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $ */ +/* $NetBSD: ohci.c,v 1.292 2019/11/29 14:15:41 gson Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.292 2019/11/29 14:15:41 gson Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2349,7 +2349,9 @@ ohci_abort_xfer(struct usbd_xfer *xfer, if (hit) { DPRINTFN(1, "set hd=0x%08jx, tl=0x%08jx", (int)p->physaddr, (int)O32TOH(sed->ed.ed_tailp), 0, 0); - sed->ed.ed_headp = HTOO32(p->physaddr); /* unlink TDs */ + /* unlink TDs, preserving toggle carry */ + sed->ed.ed_headp = HTOO32(p->physaddr | + (O32TOH(sed->ed.ed_headp) & OHCI_TOGGLECARRY)); usb_syncmem(>dma, sed->offs + offsetof(ohci_ed_t, ed_headp), sizeof(sed->ed.ed_headp),
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Fri Nov 29 14:13:04 UTC 2019 Modified Files: src/sys/dev/usb: ohci.c Log Message: Preserve the toggleCarry bit in the Endpoint Descriptor when handling a DataUnderrun condition. Fixes PR kern/54070. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Fri Nov 29 14:13:04 UTC 2019 Modified Files: src/sys/dev/usb: ohci.c Log Message: Preserve the toggleCarry bit in the Endpoint Descriptor when handling a DataUnderrun condition. Fixes PR kern/54070. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.290 src/sys/dev/usb/ohci.c:1.291 --- src/sys/dev/usb/ohci.c:1.290 Sun Aug 11 22:55:03 2019 +++ src/sys/dev/usb/ohci.c Fri Nov 29 14:13:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.290 2019/08/11 22:55:03 mrg Exp $ */ +/* $NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.290 2019/08/11 22:55:03 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1515,8 +1515,9 @@ ohci_softintr(void *v) ohci_soft_ed_t *sed = opipe->sed; - /* clear halt and TD chain */ - sed->ed.ed_headp = HTOO32(p->physaddr); + /* clear halt and TD chain, preserving toggle carry */ + sed->ed.ed_headp = HTOO32(p->physaddr | + (O32TOH(sed->ed.ed_headp) & OHCI_TOGGLECARRY)); usb_syncmem(>dma, sed->offs + offsetof(ohci_ed_t, ed_headp), sizeof(sed->ed.ed_headp),
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Tue Nov 26 10:34:16 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: Change 0x%jx -> %#jx as suggested by christos. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Tue Nov 26 10:34:16 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: Change 0x%jx -> %#jx as suggested by christos. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.74 src/sys/dev/usb/if_urtwn.c:1.75 --- src/sys/dev/usb/if_urtwn.c:1.74 Tue Nov 26 10:24:17 2019 +++ src/sys/dev/usb/if_urtwn.c Tue Nov 26 10:34:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.75 2019/11/26 10:34:16 gson Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.75 2019/11/26 10:34:16 gson Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -954,7 +954,7 @@ urtwn_write_region_1(struct urtwn_softc USETW(req.wLength, len); error = usbd_do_request(sc->sc_udev, , buf); if (error != USBD_NORMAL_COMPLETION) { - DPRINTFN(DBG_REG, "error=%jd: addr=0x%jx, len=%jd", + DPRINTFN(DBG_REG, "error=%jd: addr=%#jx, len=%jd", error, addr, len, 0); } return error; @@ -965,7 +965,7 @@ urtwn_write_1(struct urtwn_softc *sc, ui { URTWNHIST_FUNC(); URTWNHIST_CALLED(); - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); urtwn_write_region_1(sc, addr, , 1); } @@ -976,7 +976,7 @@ urtwn_write_2(struct urtwn_softc *sc, ui uint8_t buf[2]; URTWNHIST_FUNC(); URTWNHIST_CALLED(); - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); buf[0] = (uint8_t)val; buf[1] = (uint8_t)(val >> 8); @@ -989,7 +989,7 @@ urtwn_write_4(struct urtwn_softc *sc, ui uint8_t buf[4]; URTWNHIST_FUNC(); URTWNHIST_CALLED(); - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); buf[0] = (uint8_t)val; buf[1] = (uint8_t)(val >> 8); @@ -1003,7 +1003,7 @@ urtwn_write_region(struct urtwn_softc *s { URTWNHIST_FUNC(); - URTWNHIST_CALLARGS("addr=0x%jx, len=0x%jx", addr, len, 0, 0); + URTWNHIST_CALLARGS("addr=%#jx, len=%#jx", addr, len, 0, 0); return urtwn_write_region_1(sc, addr, buf, len); } @@ -1024,7 +1024,7 @@ urtwn_read_region_1(struct urtwn_softc * USETW(req.wLength, len); error = usbd_do_request(sc->sc_udev, , buf); if (error != USBD_NORMAL_COMPLETION) { - DPRINTFN(DBG_REG, "error=%jd: addr=0x%jx, len=%jd", + DPRINTFN(DBG_REG, "error=%jd: addr=%#jx, len=%jd", error, addr, len, 0); } return error; @@ -1040,7 +1040,7 @@ urtwn_read_1(struct urtwn_softc *sc, uin if (urtwn_read_region_1(sc, addr, , 1) != USBD_NORMAL_COMPLETION) return 0xff; - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); return val; } @@ -1056,7 +1056,7 @@ urtwn_read_2(struct urtwn_softc *sc, uin return 0x; val = LE_READ_2([0]); - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); return val; } @@ -1072,7 +1072,7 @@ urtwn_read_4(struct urtwn_softc *sc, uin return 0x; val = LE_READ_4([0]); - DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0); + DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", addr, val, 0, 0); return val; } @@ -1452,7 +1452,7 @@ urtwn_read_rom(struct urtwn_softc *sc) sc->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY); DPRINTFN(DBG_INIT, - "PA setting=0x%jx, board=0x%jx, regulatory=%jd", + "PA setting=%#jx, board=%#jx, regulatory=%jd", sc->pa_setting, sc->board_type, sc->regulatory, 0); IEEE80211_ADDR_COPY(ic->ic_myaddr, rom->macaddr); @@ -1610,8 +1610,8 @@ urtwn_ra_init(struct urtwn_softc *sc) } else { mode = R92C_RAID_11BG; } - DPRINTFN(DBG_INIT, "mode=0x%jx", mode, 0, 0, 0); - DPRINTFN(DBG_INIT, "rates=0x%jx, basicrates=0x%jx, " + DPRINTFN(DBG_INIT, "mode=%#jx", mode, 0, 0, 0); + DPRINTFN(DBG_INIT, "rates=%#jx, basicrates=%#jx, " "maxrate=%jx, maxbasicrate=%jx", rates, basicrates, maxrate, maxbasicrate); @@ -3571,7 +3571,7 @@ urtwn_r92c_dma_init(struct urtwn_softc * /* Get Tx queues to USB endpoints mapping. */ hashq = hasnq = haslq = 0; reg = urtwn_read_2(sc, R92C_USB_EP + 1); - DPRINTFN(DBG_INIT, "USB endpoints mapping 0x%jx", reg, 0, 0, 0); + DPRINTFN(DBG_INIT, "USB endpoints mapping %#jx", reg, 0, 0, 0); if (MS(reg, R92C_USB_EP_HQ) != 0) hashq = 1; if (MS(reg, R92C_USB_EP_NQ) != 0)
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Tue Nov 26 10:24:17 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: Convert debug printfs to usbhist. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: gson Date: Tue Nov 26 10:24:17 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: Convert debug printfs to usbhist. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.73 src/sys/dev/usb/if_urtwn.c:1.74 --- src/sys/dev/usb/if_urtwn.c:1.73 Thu Oct 10 23:30:02 2019 +++ src/sys/dev/usb/if_urtwn.c Tue Nov 26 10:24:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v #include #include #include +#include #include #include @@ -95,10 +96,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v #define DBG_REG __BIT(6) #define DBG_ALL 0xU u_int urtwn_debug = 0; -#define DPRINTFN(n, s) \ - do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0) +#define DPRINTFN(n, fmt, a, b, c, d) do { \ + if (urtwn_debug & (n)) {\ + KERNHIST_LOG(usbhist, fmt, a, b, c, d); \ + } \ +} while (/*CONSTCOND*/0) +#define URTWNHIST_FUNC() USBHIST_FUNC() +#define URTWNHIST_CALLED() do { \ + if (urtwn_debug & DBG_FN) {\ + KERNHIST_CALLED(usbhist); \ + } \ +} while(/*CONSTCOND*/0) +#define URTWNHIST_CALLARGS(fmt, a, b, c, d) do { \ + if (urtwn_debug & DBG_FN) {\ + KERNHIST_CALLARGS(usbhist, fmt, a, b, c, d); \ + } \ +} while(/*CONSTCOND*/0) #else -#define DPRINTFN(n, s) +#define DPRINTFN(n, fmt, a, b, c, d) +#define URTWNHIST_FUNC() +#define URTWNHIST_CALLED() +#define URTWNHIST_CALLARGS(fmt, a, b, c, d) #endif #define URTWN_DEV(v,p) { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, 0 } @@ -350,6 +368,8 @@ urtwn_attach(device_t parent, device_t s size_t i; int error; + URTWNHIST_FUNC(); URTWNHIST_CALLED(); + sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; @@ -363,8 +383,6 @@ urtwn_attach(device_t parent, device_t s aprint_naive("\n"); aprint_normal("\n"); - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); - devinfop = usbd_devinfo_alloc(sc->sc_udev, 0); aprint_normal_dev(self, "%s\n", devinfop); usbd_devinfo_free(devinfop); @@ -539,7 +557,7 @@ urtwn_detach(device_t self, int flags) struct ifnet *ifp = >sc_if; int s; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); pmf_device_deregister(self); @@ -589,7 +607,7 @@ urtwn_activate(device_t self, enum devac { struct urtwn_softc *sc = device_private(self); - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); switch (act) { case DVACT_DEACTIVATE: @@ -611,7 +629,7 @@ urtwn_open_pipes(struct urtwn_softc *sc) size_t i, ntx = 0, nrx = 0; int error; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); /* Determine the number of bulk-out pipes. */ id = usbd_get_interface_descriptor(sc->sc_iface); @@ -641,8 +659,8 @@ urtwn_open_pipes(struct urtwn_softc *sc) "%zd: invalid number of Tx bulk pipes\n", ntx); return EIO; } - DPRINTFN(DBG_INIT, ("%s: %s: found %zd/%zd bulk-in/out pipes\n", - device_xname(sc->sc_dev), __func__, nrx, ntx)); + DPRINTFN(DBG_INIT, "found %jd/%jd bulk-in/out pipes", + nrx, ntx, 0, 0); sc->rx_npipe = nrx; sc->tx_npipe = ntx; @@ -688,7 +706,7 @@ urtwn_close_pipes(struct urtwn_softc *sc struct usbd_pipe *pipe; size_t i; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); /* Close Rx pipes. */ CTASSERT(sizeof(pipe) == sizeof(void *)); @@ -715,7 +733,7 @@ urtwn_alloc_rx_list(struct urtwn_softc * size_t i; int error = 0; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); for (size_t j = 0; j < sc->rx_npipe; j++) { TAILQ_INIT(>rx_free_list[j]); @@ -747,7 +765,7 @@ urtwn_free_rx_list(struct urtwn_softc *s struct usbd_xfer *xfer; size_t i; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED(); /* NB: Caller must abort pipe first. */ for (size_t j = 0; j < sc->rx_npipe; j++) { @@ -767,7 +785,7 @@ urtwn_alloc_tx_list(struct urtwn_softc * size_t i; int error = 0; - DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + URTWNHIST_FUNC(); URTWNHIST_CALLED();
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Nov 17 11:28:48 UTC 2019 Modified Files: src/sys/dev/usb: vhci.c Log Message: Not a bug strictly speaking, but compute the address only after the length checks, for clarity and to appease kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/vhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/vhci.c diff -u src/sys/dev/usb/vhci.c:1.3 src/sys/dev/usb/vhci.c:1.4 --- src/sys/dev/usb/vhci.c:1.3 Thu Oct 3 05:13:23 2019 +++ src/sys/dev/usb/vhci.c Sun Nov 17 11:28:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vhci.c,v 1.3 2019/10/03 05:13:23 maxv Exp $ */ +/* $NetBSD: vhci.c,v 1.4 2019/11/17 11:28:48 maxv Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.3 2019/10/03 05:13:23 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.4 2019/11/17 11:28:48 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -376,8 +376,6 @@ vhci_roothub_ctrl(struct usbd_bus *bus, value = UGETW(req->wValue); index = UGETW(req->wIndex); - port = >sc_port[VHCI_INDEX2PORT(index)]; - #define C(x,y) ((x) | ((y) << 8)) switch (C(req->bRequest, req->bmRequestType)) { case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE): @@ -414,6 +412,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = >sc_port[VHCI_INDEX2PORT(index)]; port->status |= UPS_C_PORT_RESET; break; case UHF_PORT_POWER: @@ -430,6 +429,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = >sc_port[VHCI_INDEX2PORT(index)]; switch (value) { case UHF_PORT_ENABLE: port->status &= ~UPS_PORT_ENABLED; @@ -463,6 +463,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = >sc_port[VHCI_INDEX2PORT(index)]; USETW(ps.wPortStatus, port->status); USETW(ps.wPortChange, port->change); totlen = uimin(len, sizeof(ps));
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Nov 17 11:28:48 UTC 2019 Modified Files: src/sys/dev/usb: vhci.c Log Message: Not a bug strictly speaking, but compute the address only after the length checks, for clarity and to appease kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/vhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: mrg Date: Wed Nov 6 07:30:59 UTC 2019 Modified Files: src/sys/dev/usb: usbnet.c Log Message: add a note about ifnet lock vs usbnet locks. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/usb/usbnet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: mrg Date: Wed Nov 6 07:30:59 UTC 2019 Modified Files: src/sys/dev/usb: usbnet.c Log Message: add a note about ifnet lock vs usbnet locks. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/usb/usbnet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbnet.c diff -u src/sys/dev/usb/usbnet.c:1.29 src/sys/dev/usb/usbnet.c:1.30 --- src/sys/dev/usb/usbnet.c:1.29 Fri Sep 13 07:55:07 2019 +++ src/sys/dev/usb/usbnet.c Wed Nov 6 07:30:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usbnet.c,v 1.29 2019/09/13 07:55:07 msaitoh Exp $ */ +/* $NetBSD: usbnet.c,v 1.30 2019/11/06 07:30:59 mrg Exp $ */ /* * Copyright (c) 2019 Matthew R. Green @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.29 2019/09/13 07:55:07 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.30 2019/11/06 07:30:59 mrg Exp $"); #include #include @@ -64,6 +64,8 @@ struct usbnet_private { * ifnet lock -> unp_lock -> unp_rxlock -> unp_txlock * unp_lock -> unp_miilock * and unp_lock may be dropped after taking unp_miilock. + * - ifnet lock is not needed for unp_lock, but if ifnet lock is + * involved, it must be taken first */ kmutex_t unp_lock; kmutex_t unp_miilock;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: isaki Date: Mon Nov 4 05:46:39 UTC 2019 Modified Files: src/sys/dev/usb: uaudio.c Log Message: Use kmem_zalloc() instead of kmem_alloc() to initialize structure. struct audio_format added a member since isaki-audio2. Fix PR kern/54662 "uaudio sometimes not recognized". To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: isaki Date: Mon Nov 4 05:46:39 UTC 2019 Modified Files: src/sys/dev/usb: uaudio.c Log Message: Use kmem_zalloc() instead of kmem_alloc() to initialize structure. struct audio_format added a member since isaki-audio2. Fix PR kern/54662 "uaudio sometimes not recognized". To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uaudio.c diff -u src/sys/dev/usb/uaudio.c:1.161 src/sys/dev/usb/uaudio.c:1.162 --- src/sys/dev/usb/uaudio.c:1.161 Thu Jun 6 12:59:33 2019 +++ src/sys/dev/usb/uaudio.c Mon Nov 4 05:46:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uaudio.c,v 1.161 2019/06/06 12:59:33 isaki Exp $ */ +/* $NetBSD: uaudio.c,v 1.162 2019/11/04 05:46:39 isaki Exp $ */ /* * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.161 2019/06/06 12:59:33 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.162 2019/11/04 05:46:39 isaki Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1795,13 +1795,12 @@ uaudio_identify_as(struct uaudio_softc * } /* build audio_format array */ - sc->sc_formats = kmem_alloc(sizeof(struct audio_format) * sc->sc_nalts, + sc->sc_formats = kmem_zalloc(sizeof(struct audio_format) * sc->sc_nalts, KM_SLEEP); sc->sc_nformats = sc->sc_nalts; for (i = 0; i < sc->sc_nalts; i++) { auf = >sc_formats[i]; t1desc = sc->sc_alts[i].asf1desc; - auf->driver_data = NULL; if (UE_GET_DIR(sc->sc_alts[i].edesc->bEndpointAddress) == UE_DIR_OUT) auf->mode = AUMODE_PLAY; else
Re: CVS commit: src/sys/dev/usb
On Thu, Oct 31, 2019 at 11:59:40AM +, Maya Rashish wrote: > Module Name: src > Committed By: maya > Date: Thu Oct 31 11:59:40 UTC 2019 > > Modified Files: > src/sys/dev/usb: if_urndis.c > > Log Message: > check if buf/bufsz are non-NULL before freeing. > > not all control messages that can be received result in buf being > initialized .. It is explicitly NULL and bufsz is zero in this case. It's not relying on an uninit value.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Thu Oct 31 11:59:40 UTC 2019 Modified Files: src/sys/dev/usb: if_urndis.c Log Message: check if buf/bufsz are non-NULL before freeing. not all control messages that can be received result in buf being initialized, we might get a spurious different control message seen in practice when swapping modes a few times on a urndis device urndis0: SAMSUNG ... autoconfiguration error: urndis0: invalid address panic: kernel diagnostic assertion "p != NULL" failed: file "/cvs/src/sys/kern/subr_kmem.c", line 263 cpu0: Begin traceback... vpanic() at netbsd:vpanic+0x178 kern_assert() at netbsd:kern_assert+0x48 kmem_intr_free() at netbsd:kmem_intr_free+0xca urndis_attach() at netbsd:urndis_attach+0x4c2 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/usb/if_urndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Thu Oct 31 11:59:40 UTC 2019 Modified Files: src/sys/dev/usb: if_urndis.c Log Message: check if buf/bufsz are non-NULL before freeing. not all control messages that can be received result in buf being initialized, we might get a spurious different control message seen in practice when swapping modes a few times on a urndis device urndis0: SAMSUNG ... autoconfiguration error: urndis0: invalid address panic: kernel diagnostic assertion "p != NULL" failed: file "/cvs/src/sys/kern/subr_kmem.c", line 263 cpu0: Begin traceback... vpanic() at netbsd:vpanic+0x178 kern_assert() at netbsd:kern_assert+0x48 kmem_intr_free() at netbsd:kmem_intr_free+0xca urndis_attach() at netbsd:urndis_attach+0x4c2 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/usb/if_urndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urndis.c diff -u src/sys/dev/usb/if_urndis.c:1.33 src/sys/dev/usb/if_urndis.c:1.34 --- src/sys/dev/usb/if_urndis.c:1.33 Tue Aug 20 06:37:06 2019 +++ src/sys/dev/usb/if_urndis.c Thu Oct 31 11:59:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndis.c,v 1.33 2019/08/20 06:37:06 mrg Exp $ */ +/* $NetBSD: if_urndis.c,v 1.34 2019/10/31 11:59:40 maya Exp $ */ /* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */ /* @@ -21,7 +21,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.33 2019/08/20 06:37:06 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.34 2019/10/31 11:59:40 maya Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1068,7 +1068,8 @@ urndis_attach(device_t parent, device_t kmem_free(buf, bufsz); } else { aprint_error("%s: invalid address\n", DEVNAME(un)); - kmem_free(buf, bufsz); + if (buf && bufsz) + kmem_free(buf, bufsz); usbnet_lock(un); usbnet_stop(un, ifp, 1); usbnet_unlock(un);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 01:30:54 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: we want to check that the allocation is going to be zero, not whether some pointer is NULL (oops). Should be the right version this time! To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uvideo.c diff -u src/sys/dev/usb/uvideo.c:1.51 src/sys/dev/usb/uvideo.c:1.52 --- src/sys/dev/usb/uvideo.c:1.51 Wed Oct 23 01:03:36 2019 +++ src/sys/dev/usb/uvideo.c Wed Oct 23 01:30:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.51 2019/10/23 01:03:36 maya Exp $ */ +/* $NetBSD: uvideo.c,v 1.52 2019/10/23 01:30:54 maya Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.51 2019/10/23 01:03:36 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.52 2019/10/23 01:30:54 maya Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -999,7 +999,7 @@ static usbd_status uvideo_unit_alloc_controls(struct uvideo_unit *vu, uint8_t size, const uint8_t *controls) { - if ((vu->vu_controls == 0) || (size == 0)) + if (size == 0) return USBD_INVAL; vu->vu_controls = kmem_alloc(sizeof(*vu->vu_controls) * size, KM_SLEEP);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 01:30:54 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: we want to check that the allocation is going to be zero, not whether some pointer is NULL (oops). Should be the right version this time! To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 01:03:36 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Check if size is zero, too. PR kern/53734 To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 01:03:36 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Check if size is zero, too. PR kern/53734 To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uvideo.c diff -u src/sys/dev/usb/uvideo.c:1.50 src/sys/dev/usb/uvideo.c:1.51 --- src/sys/dev/usb/uvideo.c:1.50 Wed Oct 23 00:52:39 2019 +++ src/sys/dev/usb/uvideo.c Wed Oct 23 01:03:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $ */ +/* $NetBSD: uvideo.c,v 1.51 2019/10/23 01:03:36 maya Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.51 2019/10/23 01:03:36 maya Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -999,7 +999,7 @@ static usbd_status uvideo_unit_alloc_controls(struct uvideo_unit *vu, uint8_t size, const uint8_t *controls) { - if (vu->vu_controls == 0) + if ((vu->vu_controls == 0) || (size == 0)) return USBD_INVAL; vu->vu_controls = kmem_alloc(sizeof(*vu->vu_controls) * size, KM_SLEEP);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 00:52:39 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Avoid kmem_alloc(0,..), which hits an assertion. PR kern/53734: Prevent kernel panic during Wide Vision FHD Camera detection To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uvideo.c diff -u src/sys/dev/usb/uvideo.c:1.49 src/sys/dev/usb/uvideo.c:1.50 --- src/sys/dev/usb/uvideo.c:1.49 Tue Oct 1 18:00:08 2019 +++ src/sys/dev/usb/uvideo.c Wed Oct 23 00:52:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $ */ +/* $NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -999,6 +999,9 @@ static usbd_status uvideo_unit_alloc_controls(struct uvideo_unit *vu, uint8_t size, const uint8_t *controls) { + if (vu->vu_controls == 0) + return USBD_INVAL; + vu->vu_controls = kmem_alloc(sizeof(*vu->vu_controls) * size, KM_SLEEP); vu->vu_control_size = size; memcpy(vu->vu_controls, controls, size);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maya Date: Wed Oct 23 00:52:39 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Avoid kmem_alloc(0,..), which hits an assertion. PR kern/53734: Prevent kernel panic during Wide Vision FHD Camera detection To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Wed Oct 16 13:11:16 UTC 2019 Modified Files: src/sys/dev/usb: if_ure.c Log Message: allocate a random mac address if on-chip mac is all zeroes. helps ure(4) on NanoPi R1. partly from ganbold@freebsd r346052. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_ure.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Wed Oct 16 13:11:16 UTC 2019 Modified Files: src/sys/dev/usb: if_ure.c Log Message: allocate a random mac address if on-chip mac is all zeroes. helps ure(4) on NanoPi R1. partly from ganbold@freebsd r346052. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_ure.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_ure.c diff -u src/sys/dev/usb/if_ure.c:1.32 src/sys/dev/usb/if_ure.c:1.33 --- src/sys/dev/usb/if_ure.c:1.32 Wed Oct 16 13:02:51 2019 +++ src/sys/dev/usb/if_ure.c Wed Oct 16 13:11:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ure.c,v 1.32 2019/10/16 13:02:51 bad Exp $ */ +/* $NetBSD: if_ure.c,v 1.33 2019/10/16 13:11:16 bad Exp $ */ /* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */ /*- @@ -30,7 +30,7 @@ /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.32 2019/10/16 13:02:51 bad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.33 2019/10/16 13:11:16 bad Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1 #endif #include +#include #include @@ -66,6 +67,9 @@ int uredebug = 0; #define DPRINTFN(n, x) #endif +#define ETHER_IS_ZERO(addr) \ + (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) + static const struct usb_devno ure_devs[] = { { USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8152 }, { USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 } @@ -848,6 +852,7 @@ ure_attach(device_t parent, device_t sel uint16_t ver; uint8_t eaddr[8]; /* 2byte padded */ char *devinfop; + uint32_t maclo, machi; aprint_naive("\n"); aprint_normal("\n"); @@ -949,6 +954,16 @@ ure_attach(device_t parent, device_t sel ure_read_mem(un, URE_PLA_BACKUP, URE_MCU_TYPE_PLA, eaddr, sizeof(eaddr)); usbnet_unlock(un); + if (ETHER_IS_ZERO(eaddr)) { + maclo = 0x00f2 | (cprng_strong32() & 0x); + machi = cprng_strong32() & 0x; + eaddr[0] = maclo & 0xff; + eaddr[1] = (maclo >> 8) & 0xff; + eaddr[2] = (maclo >> 16) & 0xff; + eaddr[3] = (maclo >> 24) & 0xff; + eaddr[4] = machi & 0xff; + eaddr[5] = (machi >> 8) & 0xff; + } memcpy(un->un_eaddr, eaddr, sizeof un->un_eaddr); struct ifnet *ifp = usbnet_ifp(un);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Wed Oct 16 13:02:51 UTC 2019 Modified Files: src/sys/dev/usb: if_ure.c Log Message: read mac address of ure version 4c10 from URE_PLA_IDR, save as 4c00. from ganbold@freebsd r346052. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/dev/usb/if_ure.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_ure.c diff -u src/sys/dev/usb/if_ure.c:1.31 src/sys/dev/usb/if_ure.c:1.32 --- src/sys/dev/usb/if_ure.c:1.31 Fri Aug 23 04:32:57 2019 +++ src/sys/dev/usb/if_ure.c Wed Oct 16 13:02:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ure.c,v 1.31 2019/08/23 04:32:57 mrg Exp $ */ +/* $NetBSD: if_ure.c,v 1.32 2019/10/16 13:02:51 bad Exp $ */ /* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */ /*- @@ -30,7 +30,7 @@ /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.31 2019/08/23 04:32:57 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.32 2019/10/16 13:02:51 bad Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -941,7 +941,8 @@ ure_attach(device_t parent, device_t sel else ure_rtl8153_init(un); - if (un->un_flags & URE_FLAG_VER_4C00) + if ((un->un_flags & URE_FLAG_VER_4C00) || + (un->un_flags & URE_FLAG_VER_4C10)) ure_read_mem(un, URE_PLA_IDR, URE_MCU_TYPE_PLA, eaddr, sizeof(eaddr)); else
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Wed Oct 16 13:02:51 UTC 2019 Modified Files: src/sys/dev/usb: if_ure.c Log Message: read mac address of ure version 4c10 from URE_PLA_IDR, save as 4c00. from ganbold@freebsd r346052. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/dev/usb/if_ure.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Thu Oct 10 23:30:02 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: use ether_snprintf instead of open coding it. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.72 src/sys/dev/usb/if_urtwn.c:1.73 --- src/sys/dev/usb/if_urtwn.c:1.72 Mon Aug 19 07:20:07 2019 +++ src/sys/dev/usb/if_urtwn.c Thu Oct 10 23:30:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.72 2019/08/19 07:20:07 mrg Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.72 2019/08/19 07:20:07 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1340,10 +1340,8 @@ urtwn_dump_rom(struct urtwn_softc *sc, s rp->usb_opt, rp->ep_setting, rp->usb_phy); aprint_normal_dev(sc->sc_dev, - "macaddr %02x:%02x:%02x:%02x:%02x:%02x\n", - rp->macaddr[0], rp->macaddr[1], - rp->macaddr[2], rp->macaddr[3], - rp->macaddr[4], rp->macaddr[5]); + "macaddr %s\n", + ether_sprintf(rp->macaddr)); aprint_normal_dev(sc->sc_dev, "string %s, subcustomer_id 0x%x\n",
CVS commit: src/sys/dev/usb
Module Name:src Committed By: bad Date: Thu Oct 10 23:30:02 UTC 2019 Modified Files: src/sys/dev/usb: if_urtwn.c Log Message: use ether_snprintf instead of open coding it. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: mlelstv Date: Tue Oct 8 07:30:58 UTC 2019 Modified Files: src/sys/dev/usb: if_run.c if_runvar.h Log Message: Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work again. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_run.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_runvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: mlelstv Date: Tue Oct 8 07:30:58 UTC 2019 Modified Files: src/sys/dev/usb: if_run.c if_runvar.h Log Message: Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work again. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_run.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_runvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_run.c diff -u src/sys/dev/usb/if_run.c:1.32 src/sys/dev/usb/if_run.c:1.33 --- src/sys/dev/usb/if_run.c:1.32 Tue Jan 22 06:47:20 2019 +++ src/sys/dev/usb/if_run.c Tue Oct 8 07:30:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $ */ +/* $NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $ */ /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ /*- @@ -18,12 +18,12 @@ */ /*- - * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver. + * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver. * http://www.ralinktech.com/ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -122,6 +122,8 @@ static const struct usb_devno run_devs[] USB_ID(ASUSTEK, RT2870_5), USB_ID(ASUSTEK, RT3070), USB_ID(ASUSTEK, RT3070_1), + USB_ID(ASUSTEK, USBN53), + USB_ID(ASUSTEK, USBN66), USB_ID(ASUSTEK2, USBN11), USB_ID(AZUREWAVE, RT2870_1), USB_ID(AZUREWAVE, RT2870_2), @@ -138,6 +140,7 @@ static const struct usb_devno run_devs[] USB_ID(BELKIN, F7D1101V2), USB_ID(BELKIN, RT2870_1), USB_ID(BELKIN, RT2870_2), + USB_ID(BELKIN, RTL8192CU_2), USB_ID(BEWAN, RT3070), USB_ID(CISCOLINKSYS, AE1000), USB_ID(CISCOLINKSYS, AM10), @@ -162,6 +165,10 @@ static const struct usb_devno run_devs[] USB_ID(CYBERTAN, RT2870), USB_ID(DLINK, RT2870), USB_ID(DLINK, RT3072), + USB_ID(DLINK, DWA127), + USB_ID(DLINK, DWA140B3), + USB_ID(DLINK, DWA160B2), + USB_ID(DLINK, DWA162), USB_ID(DLINK2, DWA130), USB_ID(DLINK2, RT2870_1), USB_ID(DLINK2, RT2870_2), @@ -203,6 +210,9 @@ static const struct usb_devno run_devs[] USB_ID(LINKSYS4, WUSB600N), USB_ID(LINKSYS4, WUSB600NV2), USB_ID(LOGITEC, LANW300NU2), + USB_ID(LOGITEC, LANW300NU2S), + USB_ID(LOGITEC, LAN_W300ANU2), + USB_ID(LOGITEC, LAN_W450ANU2E), USB_ID(LOGITEC, RT2870_1), USB_ID(LOGITEC, RT2870_2), USB_ID(LOGITEC, RT2870_3), @@ -257,6 +267,7 @@ static const struct usb_devno run_devs[] USB_ID(RALINK, RT3072), USB_ID(RALINK, RT3370), USB_ID(RALINK, RT3572), + USB_ID(RALINK, RT3573), USB_ID(RALINK, RT5370), USB_ID(RALINK, RT5572), USB_ID(RALINK, RT8070), @@ -276,9 +287,11 @@ static const struct usb_devno run_devs[] USB_ID(SITECOMEU, RT2870_2), USB_ID(SITECOMEU, RT2870_3), USB_ID(SITECOMEU, RT3070_1), + USB_ID(SITECOMEU, RT3070_3), USB_ID(SITECOMEU, RT3072_3), USB_ID(SITECOMEU, RT3072_4), USB_ID(SITECOMEU, RT3072_5), + USB_ID(SITECOMEU, RT3072_6), USB_ID(SITECOMEU, WL302), USB_ID(SITECOMEU, WL315), USB_ID(SITECOMEU, WL321), @@ -352,7 +365,7 @@ static int run_rt3070_rf_write(struct r static int run_bbp_read(struct run_softc *, uint8_t, uint8_t *); static int run_bbp_write(struct run_softc *, uint8_t, uint8_t); static int run_mcu_cmd(struct run_softc *, uint8_t, uint16_t); -static const char * run_get_rf(int); +static const char * run_get_rf(uint16_t); static void run_rt3593_get_txpower(struct run_softc *); static void run_get_txpower(struct run_softc *); static int run_read_eeprom(struct run_softc *); @@ -850,6 +863,11 @@ run_alloc_tx_ring(struct run_softc *sc, { struct run_tx_ring *txq = >txq[qid]; int i, error; + uint16_t txwisize; + + txwisize = sizeof(struct rt2860_txwi); + if (sc->mac_ver == 0x5592) + txwisize += sizeof(uint32_t); txq->cur = txq->queued = 0; @@ -870,8 +888,7 @@ run_alloc_tx_ring(struct run_softc *sc, data->buf = usbd_get_buffer(data->xfer); /* zeroize the TXD + TXWI part */ - memset(data->buf, 0, sizeof(struct rt2870_txd) + - sizeof(struct rt2860_txwi)); + memset(data->buf, 0, sizeof(struct rt2870_txd) + txwisize); } if (error != 0) fail: run_free_tx_ring(sc, qid); @@ -942,7 +959,9 @@ run_load_microcode(struct run_softc *sc) return error; usbd_delay_ms(sc->sc_udev, 10); + run_write(sc, RT2860_H2M_BBPAGENT, 0); run_write(sc, RT2860_H2M_MAILBOX, 0); + run_write(sc, RT2860_H2M_INTSRC, 0); if ((error = run_mcu_cmd(sc, RT2860_MCU_CMD_RFRESET, 0)) != 0) return error; @@ -1106,6 +1125,7 @@ run_efuse_read(struct run_softc *sc, uin if ((error = run_read(sc, reg, )) != 0) return error; + tmp >>= (8 * (addr & 0x3)); *val = (addr & 1) ? tmp >> 16 : tmp & 0x; return 0; } @@ -1315,7 +1335,7 @@ b4inc(uint32_t b32, int8_t delta) } static const
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Oct 7 09:37:16 UTC 2019 Modified Files: src/sys/dev/usb: if_udav.c Log Message: Avoid a warning To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/usb/if_udav.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_udav.c diff -u src/sys/dev/usb/if_udav.c:1.71 src/sys/dev/usb/if_udav.c:1.72 --- src/sys/dev/usb/if_udav.c:1.71 Fri Aug 23 04:32:57 2019 +++ src/sys/dev/usb/if_udav.c Mon Oct 7 09:37:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_udav.c,v 1.71 2019/08/23 04:32:57 mrg Exp $ */ +/* $NetBSD: if_udav.c,v 1.72 2019/10/07 09:37:16 skrll Exp $ */ /* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */ /* @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.71 2019/08/23 04:32:57 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.72 2019/10/07 09:37:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -864,7 +864,7 @@ udav_mii_statchg(struct ifnet *ifp) if (usbnet_isdying(un)) return; - if (mii->mii_media_status & IFM_ACTIVE && + if ((mii->mii_media_status & IFM_ACTIVE) && IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { DPRINTF(("%s: %s: got link\n", device_xname(un->un_dev), __func__));
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Oct 7 09:37:16 UTC 2019 Modified Files: src/sys/dev/usb: if_udav.c Log Message: Avoid a warning To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/usb/if_udav.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: martin Date: Sun Oct 6 17:23:05 UTC 2019 Modified Files: src/sys/dev/usb: usbdevs.h usbdevs_data.h Log Message: Regen To generate a diff of this commit: cvs rdiff -u -r1.763 -r1.764 src/sys/dev/usb/usbdevs.h \ src/sys/dev/usb/usbdevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs.h diff -u src/sys/dev/usb/usbdevs.h:1.763 src/sys/dev/usb/usbdevs.h:1.764 --- src/sys/dev/usb/usbdevs.h:1.763 Mon Aug 26 02:02:16 2019 +++ src/sys/dev/usb/usbdevs.h Sun Oct 6 17:23:05 2019 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs.h,v 1.763 2019/08/26 02:02:16 mrg Exp $ */ +/* $NetBSD: usbdevs.h,v 1.764 2019/10/06 17:23:05 martin Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.773 2019/08/26 02:01:18 mrg Exp + * NetBSD: usbdevs,v 1.774 2019/10/06 17:22:29 martin Exp */ /*- @@ -3374,6 +3374,9 @@ #define USB_PRODUCT_TPLINK_RTL8192CU 0x0100 /* RTL8192CU */ #define USB_PRODUCT_TPLINK_RTL8192EU 0x0109 /* RTL8192EU */ #define USB_PRODUCT_TPLINK_RTL8188EU 0x010c /* RTL8188EU */ +#define USB_PRODUCT_TPLINK_T4UV2 0x010d /* Archer T4U ver 2 */ +#define USB_PRODUCT_TPLINK_T4UHV2 0x010e /* Archer T4UH ver 2 */ +#define USB_PRODUCT_TPLINK_T2UNANO 0x011e /* Archer T2U Nano */ /* Trek Technology products */ #define USB_PRODUCT_TREK_THUMBDRIVE 0x /* ThumbDrive */ Index: src/sys/dev/usb/usbdevs_data.h diff -u src/sys/dev/usb/usbdevs_data.h:1.763 src/sys/dev/usb/usbdevs_data.h:1.764 --- src/sys/dev/usb/usbdevs_data.h:1.763 Mon Aug 26 02:02:16 2019 +++ src/sys/dev/usb/usbdevs_data.h Sun Oct 6 17:23:05 2019 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs_data.h,v 1.763 2019/08/26 02:02:16 mrg Exp $ */ +/* $NetBSD: usbdevs_data.h,v 1.764 2019/10/06 17:23:05 martin Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.773 2019/08/26 02:01:18 mrg Exp + * NetBSD: usbdevs,v 1.774 2019/10/06 17:22:29 martin Exp */ /*- @@ -4620,60 +4620,66 @@ static const uint16_t usb_products[] = { 16991, 0, USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8188EU, 5204, 0, + USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_T4UV2, + 19456, 19463, 7494, 6496, 0, + USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_T4UHV2, + 19456, 19467, 7494, 6496, 0, + USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_T2UNANO, + 19456, 19472, 6835, 0, USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE, - 19456, 0, + 19476, 0, USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE_8MB, - 19456, 19467, 0, + 19476, 19487, 0, USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8192CU, 5194, 0, USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8188CU, 5214, 0, USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, - 19471, 6895, 4919, 0, + 19491, 6895, 4919, 0, USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_UPS, 3174, 3180, 480, 0, USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_SMARTLCD, - 19476, 480, 0, + 19496, 480, 0, USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_AVR550U, - 3174, 3180, 19485, 0, + 3174, 3180, 19505, 0, USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_T33521, - 19493, 19501, 0, + 19513, 19521, 0, USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_XXX1100, - 15862, 19509, 0, + 15862, 19529, 0, USB_VENDOR_TSUNAMI, USB_PRODUCT_TSUNAMI_SM2000, - 19514, 0, + 19534, 0, USB_VENDOR_TWINMOS, USB_PRODUCT_TWINMOS_G240, - 19522, 0, + 19542, 0, USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_1200UBPLUS, 11180, 14782, 11070, 7196, 0, USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_T14BR, - 19527, 19533, 6805, 0, + 19547, 19553, 6805, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U, - 19539, 5701, 19545, 0, + 19559, 5701, 19565, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U, - 19539, 19553, 19545, 0, + 19559, 19573, 19565, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U, - 19539, 19559, 19545, 0, + 19559, 19579, 19565, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400, - 19539, 19565, 19545, 0, + 19559, 19585, 19565, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2100U, - 19539, 19570, 19545, 0, + 19559, 19590, 19565, 0, USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U, - 19539, 19576, 19545, 0, + 19559, 19596, 19565, 0, USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB_A, - 19582, 0, + 19602, 0, USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB, - 19594, 0, + 19614, 0, USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UBC1, - 19594, 9167, 0, + 19614, 9167, 0, USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_RT2870_1, 5073, 0, USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW645UB, - 19604, 0, + 19624, 0,
CVS commit: src/sys/dev/usb
Module Name:src Committed By: martin Date: Sun Oct 6 17:23:05 UTC 2019 Modified Files: src/sys/dev/usb: usbdevs.h usbdevs_data.h Log Message: Regen To generate a diff of this commit: cvs rdiff -u -r1.763 -r1.764 src/sys/dev/usb/usbdevs.h \ src/sys/dev/usb/usbdevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: martin Date: Sun Oct 6 17:22:29 UTC 2019 Modified Files: src/sys/dev/usb: usbdevs Log Message: Add a few TP-Link "Archer" wlan devices To generate a diff of this commit: cvs rdiff -u -r1.773 -r1.774 src/sys/dev/usb/usbdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: martin Date: Sun Oct 6 17:22:29 UTC 2019 Modified Files: src/sys/dev/usb: usbdevs Log Message: Add a few TP-Link "Archer" wlan devices To generate a diff of this commit: cvs rdiff -u -r1.773 -r1.774 src/sys/dev/usb/usbdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs diff -u src/sys/dev/usb/usbdevs:1.773 src/sys/dev/usb/usbdevs:1.774 --- src/sys/dev/usb/usbdevs:1.773 Mon Aug 26 02:01:18 2019 +++ src/sys/dev/usb/usbdevs Sun Oct 6 17:22:29 2019 @@ -1,4 +1,4 @@ -$NetBSD: usbdevs,v 1.773 2019/08/26 02:01:18 mrg Exp $ +$NetBSD: usbdevs,v 1.774 2019/10/06 17:22:29 martin Exp $ /*- * Copyright (c) 1998-2004 The NetBSD Foundation, Inc. @@ -3367,6 +3367,9 @@ product TOSHIBA HSDPA_MODEM_EU870DT1 0x1 product TPLINK RTL8192CU 0x0100 RTL8192CU product TPLINK RTL8192EU 0x0109 RTL8192EU product TPLINK RTL8188EU 0x010c RTL8188EU +product TPLINK T4UV2 0x010d Archer T4U ver 2 +product TPLINK T4UHV2 0x010e Archer T4UH ver 2 +product TPLINK T2UNANO 0x011e Archer T2U Nano /* Trek Technology products */ product TREK THUMBDRIVE 0x ThumbDrive
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:20:31 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Fix memory leaks. Was wondering where memory had gone after several hours of attach/detach with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:20:31 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Fix memory leaks. Was wondering where memory had gone after several hours of attach/detach with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.240 src/sys/dev/usb/usb_subr.c:1.241 --- src/sys/dev/usb/usb_subr.c:1.240 Sun Sep 15 09:24:38 2019 +++ src/sys/dev/usb/usb_subr.c Thu Oct 3 05:20:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $ */ +/* $NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1479,6 +1479,15 @@ usbd_remove_device(struct usbd_device *d up->up_dev = NULL; dev->ud_bus->ub_devices[usb_addr2dindex(dev->ud_addr)] = NULL; + if (dev->ud_vendor != NULL) { + kmem_free(dev->ud_vendor, USB_MAX_ENCODED_STRING_LEN); + } + if (dev->ud_product != NULL) { + kmem_free(dev->ud_product, USB_MAX_ENCODED_STRING_LEN); + } + if (dev->ud_serial != NULL) { + kmem_free(dev->ud_serial, USB_MAX_ENCODED_STRING_LEN); + } kmem_free(dev, sizeof(*dev)); }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:16:16 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: More less kmem_zalloc(0). To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:16:16 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: More less kmem_zalloc(0). To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umidi.c diff -u src/sys/dev/usb/umidi.c:1.79 src/sys/dev/usb/umidi.c:1.80 --- src/sys/dev/usb/umidi.c:1.79 Sun Sep 15 09:18:17 2019 +++ src/sys/dev/usb/umidi.c Thu Oct 3 05:16:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $ */ +/* $NetBSD: umidi.c,v 1.80 2019/10/03 05:16:16 maxv Exp $ */ /* * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.80 2019/10/03 05:16:16 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1081,9 +1081,10 @@ alloc_all_jacks(struct umidi_softc *sc) cn_spec = NULL; /* allocate/initialize structures */ - sc->sc_jacks = - kmem_zalloc(sizeof(*sc->sc_out_jacks)*(sc->sc_in_num_jacks - + sc->sc_out_num_jacks), KM_SLEEP); + if (sc->sc_in_num_jacks == 0 && sc->sc_out_num_jacks == 0) + return USBD_INVAL; + sc->sc_jacks = kmem_zalloc(sizeof(*sc->sc_out_jacks) * + (sc->sc_in_num_jacks + sc->sc_out_num_jacks), KM_SLEEP); if (!sc->sc_jacks) return USBD_NOMEM; sc->sc_out_jacks = @@ -1154,8 +1155,8 @@ free_all_jacks(struct umidi_softc *sc) mutex_enter(>sc_lock); jacks = sc->sc_jacks; - len = sizeof(*sc->sc_out_jacks) - * (sc->sc_in_num_jacks + sc->sc_out_num_jacks); + len = sizeof(*sc->sc_out_jacks) * + (sc->sc_in_num_jacks + sc->sc_out_num_jacks); sc->sc_jacks = sc->sc_in_jacks = sc->sc_out_jacks = NULL; mutex_exit(>sc_lock);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Thu Oct 3 05:13:24 UTC 2019 Modified Files: src/sys/dev/usb: vhci.c Log Message: Improvements: - Don't process packets if the USB device is detached. Contrary to the other HCIs, vHCI has no timeout, so we never collect the pending packets, and must drop them synchronously. - Fix refcounting bug in vhci_device_ctrl_abort. - Implement vhci_activate. - Add a few KASSERTs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/vhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: christos Date: Thu Sep 26 01:35:08 UTC 2019 Modified Files: src/sys/dev/usb: usbdivar.h Log Message: subdevlen is an array length, make it unsigned To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usbdivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: christos Date: Thu Sep 26 01:35:08 UTC 2019 Modified Files: src/sys/dev/usb: usbdivar.h Log Message: subdevlen is an array length, make it unsigned To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/usbdivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdivar.h diff -u src/sys/dev/usb/usbdivar.h:1.118 src/sys/dev/usb/usbdivar.h:1.119 --- src/sys/dev/usb/usbdivar.h:1.118 Sat Jan 26 21:08:42 2019 +++ src/sys/dev/usb/usbdivar.h Wed Sep 25 21:35:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdivar.h,v 1.118 2019/01/27 02:08:42 pgoyette Exp $ */ +/* $NetBSD: usbdivar.h,v 1.119 2019/09/26 01:35:08 christos Exp $ */ /* * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. @@ -203,7 +203,7 @@ struct usbd_device { const struct usbd_quirks *ud_quirks; /* device quirks, always set */ struct usbd_hub *ud_hub; /* only if this is a hub */ - int ud_subdevlen; /* array length of following */ + u_int ud_subdevlen; /* array length of following */ device_t *ud_subdevs; /* sub-devices */ int ud_nifaces_claimed; /* number of ifaces in use */ void *ud_hcpriv;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: dsainty Date: Sun Sep 22 07:29:16 UTC 2019 Modified Files: src/sys/dev/usb: ubt.c udsir.c Log Message: Purge an ancient email address, use dsai...@netbsd.org instead To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/ubt.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/usb/udsir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ubt.c diff -u src/sys/dev/usb/ubt.c:1.62 src/sys/dev/usb/ubt.c:1.63 --- src/sys/dev/usb/ubt.c:1.62 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/ubt.c Sun Sep 22 07:29:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ubt.c,v 1.62 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: ubt.c,v 1.63 2019/09/22 07:29:16 dsainty Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -36,7 +36,7 @@ * * This code is derived from software contributed to The NetBSD Foundation * by Lennart Augustsson (lenn...@augustsson.net) and - * David Sainty (david.sai...@dtsp.co.nz). + * David Sainty (dsai...@netbsd.org). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.62 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.63 2019/09/22 07:29:16 dsainty Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" Index: src/sys/dev/usb/udsir.c diff -u src/sys/dev/usb/udsir.c:1.8 src/sys/dev/usb/udsir.c:1.9 --- src/sys/dev/usb/udsir.c:1.8 Mon Jul 22 06:24:57 2019 +++ src/sys/dev/usb/udsir.c Sun Sep 22 07:29:16 2019 @@ -1,11 +1,11 @@ -/* $NetBSD: udsir.c,v 1.8 2019/07/22 06:24:57 skrll Exp $ */ +/* $NetBSD: udsir.c,v 1.9 2019/09/22 07:29:16 dsainty Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by David Sainty + * by David Sainty * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udsir.c,v 1.8 2019/07/22 06:24:57 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udsir.c,v 1.9 2019/09/22 07:29:16 dsainty Exp $"); #include #include
CVS commit: src/sys/dev/usb
Module Name:src Committed By: dsainty Date: Sun Sep 22 07:29:16 UTC 2019 Modified Files: src/sys/dev/usb: ubt.c udsir.c Log Message: Purge an ancient email address, use dsai...@netbsd.org instead To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/ubt.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/usb/udsir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: dsainty Date: Sun Sep 22 07:28:35 UTC 2019 Modified Files: src/sys/dev/usb: ustir.c ustirreg.h Log Message: Purge an ancient email address, use dsai...@netbsd.org instead To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/usb/ustir.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/ustirreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ustir.c diff -u src/sys/dev/usb/ustir.c:1.41 src/sys/dev/usb/ustir.c:1.42 --- src/sys/dev/usb/ustir.c:1.41 Sat Sep 14 15:21:19 2019 +++ src/sys/dev/usb/ustir.c Sun Sep 22 07:28:35 2019 @@ -1,11 +1,11 @@ -/* $NetBSD: ustir.c,v 1.41 2019/09/14 15:21:19 maxv Exp $ */ +/* $NetBSD: ustir.c,v 1.42 2019/09/22 07:28:35 dsainty Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by David Sainty + * by David Sainty * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ustir.c,v 1.41 2019/09/14 15:21:19 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ustir.c,v 1.42 2019/09/22 07:28:35 dsainty Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" Index: src/sys/dev/usb/ustirreg.h diff -u src/sys/dev/usb/ustirreg.h:1.4 src/sys/dev/usb/ustirreg.h:1.5 --- src/sys/dev/usb/ustirreg.h:1.4 Mon Apr 28 20:24:01 2008 +++ src/sys/dev/usb/ustirreg.h Sun Sep 22 07:28:35 2019 @@ -1,11 +1,11 @@ -/* $NetBSD: ustirreg.h,v 1.4 2008/04/28 20:24:01 martin Exp $ */ +/* $NetBSD: ustirreg.h,v 1.5 2019/09/22 07:28:35 dsainty Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by David Sainty + * by David Sainty * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
CVS commit: src/sys/dev/usb
Module Name:src Committed By: dsainty Date: Sun Sep 22 07:28:35 UTC 2019 Modified Files: src/sys/dev/usb: ustir.c ustirreg.h Log Message: Purge an ancient email address, use dsai...@netbsd.org instead To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/usb/ustir.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/ustirreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:24:39 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Reset ud_pipe0 to NULL before calling usbd_setup_pipe_flags(). If the call fails we call usbd_remove_device(), which tries to free ud_pipe0, but it was already freed. While here, add two sanity checks, to prevent possible surprises. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.239 src/sys/dev/usb/usb_subr.c:1.240 --- src/sys/dev/usb/usb_subr.c:1.239 Wed Aug 28 01:44:39 2019 +++ src/sys/dev/usb/usb_subr.c Sun Sep 15 09:24:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.239 2019/08/28 01:44:39 mrg Exp $ */ +/* $NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.239 2019/08/28 01:44:39 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.240 2019/09/15 09:24:38 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1353,6 +1353,7 @@ usbd_new_device(device_t parent, struct /* Re-establish the default pipe with the new MPS. */ usbd_kill_pipe(dev->ud_pipe0); + dev->ud_pipe0 = NULL; err = usbd_setup_pipe_flags(dev, 0, >ud_ep0, USBD_DEFAULT_INTERVAL, >ud_pipe0, USBD_MPSAFE); if (err) { @@ -1378,6 +1379,7 @@ usbd_new_device(device_t parent, struct /* Re-establish the default pipe with the new address. */ usbd_kill_pipe(dev->ud_pipe0); + dev->ud_pipe0 = NULL; err = usbd_setup_pipe_flags(dev, 0, >ud_ep0, USBD_DEFAULT_INTERVAL, >ud_pipe0, USBD_MPSAFE); if (err) { @@ -1431,6 +1433,10 @@ usbd_reload_device_desc(struct usbd_devi err = usbd_get_device_desc(dev, udd); if (err) return err; + if (udd->bDescriptorType != UDESC_DEVICE) + return USBD_INVAL; + if (udd->bLength < USB_DEVICE_DESCRIPTOR_SIZE) + return USBD_INVAL; DPRINTFN(15, "bLength %5ju", udd->bLength, 0, 0, 0); DPRINTFN(15, "bDescriptorType %5ju", udd->bDescriptorType, 0, 0, 0);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:24:39 UTC 2019 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: Reset ud_pipe0 to NULL before calling usbd_setup_pipe_flags(). If the call fails we call usbd_remove_device(), which tries to free ud_pipe0, but it was already freed. While here, add two sanity checks, to prevent possible surprises. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:21:36 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Add missing length checks on descriptors, to prevent buffer overflows. Found via KASAN+vHCI. Some remain however, but it looks like the code needs to be re-thought along the way, so it will be fixed later. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uvideo.c diff -u src/sys/dev/usb/uvideo.c:1.47 src/sys/dev/usb/uvideo.c:1.48 --- src/sys/dev/usb/uvideo.c:1.47 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/uvideo.c Sun Sep 15 09:21:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.47 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: uvideo.c,v 1.48 2019/09/15 09:21:36 maxv Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.47 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.48 2019/09/15 09:21:36 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -527,6 +527,12 @@ uvideo_attach(device_t parent, device_t (ifdesc = usb_desc_iter_next_interface()) != NULL; ++ifaceidx) { + if (ifdesc->bLength < USB_INTERFACE_DESCRIPTOR_SIZE) { + DPRINTFN(50, ("uvideo_attach: " + "ignoring incorrect descriptor len=%d\n", + ifdesc->bLength)); + continue; + } if (ifdesc->bInterfaceClass != UICLASS_VIDEO) { DPRINTFN(50, ("uvideo_attach: " "ignoring non-uvc interface: " @@ -884,13 +890,17 @@ uvideo_unit_init(struct uvideo_unit *vu, switch (desc->bDescriptorSubtype) { case UDESC_INPUT_TERMINAL: + if (desc->bLength < sizeof(*input)) + return USBD_INVAL; input = (const uvideo_input_terminal_descriptor_t *)desc; switch (UGETW(input->wTerminalType)) { case UVIDEO_ITT_CAMERA: + if (desc->bLength < sizeof(*camera)) +return USBD_INVAL; camera = (const uvideo_camera_terminal_descriptor_t *)desc; - ct = >u.vu_camera; + ct = >u.vu_camera; ct->ct_objective_focal_min = UGETW(camera->wObjectiveFocalLengthMin); ct->ct_objective_focal_max = @@ -911,12 +921,16 @@ uvideo_unit_init(struct uvideo_unit *vu, case UDESC_OUTPUT_TERMINAL: break; case UDESC_SELECTOR_UNIT: + if (desc->bLength < sizeof(*selector)) + return USBD_INVAL; selector = (const uvideo_selector_unit_descriptor_t *)desc; uvideo_unit_alloc_sources(vu, selector->bNrInPins, selector->baSourceID); break; case UDESC_PROCESSING_UNIT: + if (desc->bLength < sizeof(*processing)) + return USBD_INVAL; processing = (const uvideo_processing_unit_descriptor_t *)desc; pu = >u.vu_processing; @@ -928,6 +942,8 @@ uvideo_unit_init(struct uvideo_unit *vu, processing->bmControls); break; case UDESC_EXTENSION_UNIT: + if (desc->bLength < sizeof(*extension)) + return USBD_INVAL; extension = (const uvideo_extension_unit_descriptor_t *)desc; /* TODO: copy guid */ @@ -1081,6 +1097,9 @@ uvideo_stream_init(struct uvideo_stream * interface descriptor, modifying the iterator. This may be called * multiple times because there may be several alternate interfaces * associated with the same interface number. */ +/* + * XXX XXX XXX: This function accesses descriptors in an unsafe manner. + */ static usbd_status uvideo_stream_init_desc(struct uvideo_stream *vs, const usb_interface_descriptor_t *ifdesc,
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:21:36 UTC 2019 Modified Files: src/sys/dev/usb: uvideo.c Log Message: Add missing length checks on descriptors, to prevent buffer overflows. Found via KASAN+vHCI. Some remain however, but it looks like the code needs to be re-thought along the way, so it will be fixed later. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/usb/uvideo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:18:17 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: Don't kmem_alloc(0) if there are no endpoints, otherwise panic. Found via vHCI. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umidi.c diff -u src/sys/dev/usb/umidi.c:1.78 src/sys/dev/usb/umidi.c:1.79 --- src/sys/dev/usb/umidi.c:1.78 Wed May 8 13:40:19 2019 +++ src/sys/dev/usb/umidi.c Sun Sep 15 09:18:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: umidi.c,v 1.78 2019/05/08 13:40:19 isaki Exp $ */ +/* $NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $ */ /* * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.78 2019/05/08 13:40:19 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -966,6 +966,8 @@ alloc_all_endpoints_genuine(struct umidi interface_desc = usbd_get_interface_descriptor(sc->sc_iface); num_ep = interface_desc->bNumEndpoints; + if (num_ep == 0) + return USBD_INVAL; sc->sc_endpoints_len = sizeof(struct umidi_endpoint) * num_ep; sc->sc_endpoints = p = kmem_zalloc(sc->sc_endpoints_len, KM_SLEEP); sc->sc_out_num_jacks = sc->sc_in_num_jacks = 0;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sun Sep 15 09:18:17 UTC 2019 Modified Files: src/sys/dev/usb: umidi.c Log Message: Don't kmem_alloc(0) if there are no endpoints, otherwise panic. Found via vHCI. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:24:23 UTC 2019 Modified Files: src/sys/dev/usb: udl.c udl.h Log Message: Fix error handling, to prevent kernel crashes at detach time. The code is slightly reorganized. Found via vHCI. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/udl.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/udl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/udl.c diff -u src/sys/dev/usb/udl.c:1.22 src/sys/dev/usb/udl.c:1.23 --- src/sys/dev/usb/udl.c:1.22 Mon Sep 3 16:29:34 2018 +++ src/sys/dev/usb/udl.c Sat Sep 14 15:24:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: udl.c,v 1.22 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: udl.c,v 1.23 2019/09/14 15:24:23 maxv Exp $ */ /*- * Copyright (c) 2009 FUKAUMI Naoki. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.22 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.23 2019/09/14 15:24:23 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -369,6 +369,7 @@ udl_attach(device_t parent, device_t sel sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; + sc->sc_init_state = UDL_INIT_NONE; devinfop = usbd_devinfo_alloc(sc->sc_udev, 0); aprint_normal_dev(sc->sc_dev, "%s\n", devinfop); @@ -399,9 +400,6 @@ udl_attach(device_t parent, device_t sel if (error != USBD_NORMAL_COMPLETION) return; - /* - * Allocate bulk command queue. - */ #ifdef UDL_EVENT_COUNTERS evcnt_attach_dynamic(>sc_ev_cmdq_get, EVCNT_TYPE_MISC, NULL, device_xname(sc->sc_dev), "udl_cmdq_get"); @@ -412,13 +410,16 @@ udl_attach(device_t parent, device_t sel evcnt_attach_dynamic(>sc_ev_cmdq_timeout, EVCNT_TYPE_MISC, NULL, device_xname(sc->sc_dev), "udl_cmdq_timeout"); #endif + cv_init(>sc_cv, device_xname(sc->sc_dev)); + mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_TTY); /* XXX for tty_lock */ + sc->sc_init_state = UDL_INIT_MIDWAY; + /* + * Allocate bulk command queue. + */ if (udl_cmdq_alloc(sc) != 0) return; - cv_init(>sc_cv, device_xname(sc->sc_dev)); - mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_TTY); /* XXX for tty_lock */ - if ((sc->sc_cmd_cur = udl_cmdq_get(sc)) == NULL) return; UDL_CMD_BUFINIT(sc); @@ -483,6 +484,8 @@ udl_attach(device_t parent, device_t sel sc->sc_thread_stop = true; kthread_create(PRI_BIO, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL, udl_update_thread, sc, >sc_thread, "udlupd"); + + sc->sc_init_state = UDL_INIT_INITED; } static int @@ -497,11 +500,13 @@ udl_detach(device_t self, int flags) usbd_abort_pipe(sc->sc_tx_pipeh); } - /* - * Free command xfer buffers. - */ - udl_cmdq_flush(sc); - udl_cmdq_free(sc); + if (sc->sc_init_state >= UDL_INIT_MIDWAY) { + /* + * Free command xfer buffers. + */ + udl_cmdq_flush(sc); + udl_cmdq_free(sc); + } if (sc->sc_tx_pipeh != NULL) { usbd_close_pipe(sc->sc_tx_pipeh); @@ -512,36 +517,45 @@ udl_detach(device_t self, int flags) */ udl_comp_unload(sc); - /* - * Free framebuffer memory. - */ - udl_fbmem_free(sc); + if (sc->sc_init_state >= UDL_INIT_INITED) { + /* + * Free framebuffer memory. + */ + udl_fbmem_free(sc); - mutex_enter(>sc_thread_mtx); - sc->sc_dying = true; - cv_broadcast(>sc_thread_cv); - mutex_exit(>sc_thread_mtx); - kthread_join(sc->sc_thread); + mutex_enter(>sc_thread_mtx); + sc->sc_dying = true; + cv_broadcast(>sc_thread_cv); + mutex_exit(>sc_thread_mtx); + kthread_join(sc->sc_thread); + cv_destroy(>sc_thread_cv); + mutex_destroy(>sc_thread_mtx); + } - cv_destroy(>sc_cv); - mutex_destroy(>sc_mtx); - cv_destroy(>sc_thread_cv); - mutex_destroy(>sc_thread_mtx); + if (sc->sc_init_state >= UDL_INIT_MIDWAY) { + cv_destroy(>sc_cv); + mutex_destroy(>sc_mtx); + } - /* - * Detach wsdisplay. - */ - if (sc->sc_wsdisplay != NULL) - config_detach(sc->sc_wsdisplay, DETACH_FORCE); + if (sc->sc_init_state >= UDL_INIT_INITED) { + /* + * Detach wsdisplay. + */ + if (sc->sc_wsdisplay != NULL) + config_detach(sc->sc_wsdisplay, DETACH_FORCE); - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); + } + if (sc->sc_init_state >= UDL_INIT_MIDWAY) { #ifdef UDL_EVENT_COUNTERS - evcnt_detach(>sc_ev_cmdq_get); - evcnt_detach(>sc_ev_cmdq_put); - evcnt_detach(>sc_ev_cmdq_wait); - evcnt_detach(>sc_ev_cmdq_timeout); + evcnt_detach(>sc_ev_cmdq_get); + evcnt_detach(>sc_ev_cmdq_put); + evcnt_detach(>sc_ev_cmdq_wait); + evcnt_detach(>sc_ev_cmdq_timeout); #endif + } return 0; } Index: src/sys/dev/usb/udl.h diff -u src/sys/dev/usb/udl.h:1.4 src/sys/dev/usb/udl.h:1.5 --- src/sys/dev/usb/udl.h:1.4 Tue Oct 18 20:17:37 2016 +++ src/sys/dev/usb/udl.h Sat Sep 14 15:24:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: udl.h,v 1.4 2016/10/18 20:17:37 nat Exp $ */ +/* $NetBSD: udl.h,v 1.5 2019/09/14 15:24:23 maxv
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:24:23 UTC 2019 Modified Files: src/sys/dev/usb: udl.c udl.h Log Message: Fix error handling, to prevent kernel crashes at detach time. The code is slightly reorganized. Found via vHCI. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/udl.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/udl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:22:31 UTC 2019 Modified Files: src/sys/dev/usb: usscanner.c Log Message: Fix NULL deref. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/usscanner.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:22:31 UTC 2019 Modified Files: src/sys/dev/usb: usscanner.c Log Message: Fix NULL deref. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/usscanner.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usscanner.c diff -u src/sys/dev/usb/usscanner.c:1.44 src/sys/dev/usb/usscanner.c:1.45 --- src/sys/dev/usb/usscanner.c:1.44 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/usscanner.c Sat Sep 14 15:22:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usscanner.c,v 1.44 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: usscanner.c,v 1.45 2019/09/14 15:22:31 maxv Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usscanner.c,v 1.44 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usscanner.c,v 1.45 2019/09/14 15:22:31 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -387,7 +387,9 @@ usscanner_detach(device_t self, int flag else rv = 0; - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + if (sc->sc_udev != NULL) + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); return rv; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:21:19 UTC 2019 Modified Files: src/sys/dev/usb: ustir.c Log Message: Fix error handling, to prevent kernel crashes at detach time. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/ustir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ustir.c diff -u src/sys/dev/usb/ustir.c:1.40 src/sys/dev/usb/ustir.c:1.41 --- src/sys/dev/usb/ustir.c:1.40 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/ustir.c Sat Sep 14 15:21:19 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ustir.c,v 1.40 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: ustir.c,v 1.41 2019/09/14 15:21:19 maxv Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ustir.c,v 1.40 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ustir.c,v 1.41 2019/09/14 15:21:19 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -96,6 +96,10 @@ struct ustir_softc { device_t sc_dev; struct usbd_device *sc_udev; struct usbd_interface *sc_iface; + enum { + USTIR_INIT_NONE, + USTIR_INIT_INITED + } sc_init_state; uint8_t *sc_ur_buf; /* Unencapsulated frame */ u_int sc_ur_framelen; @@ -250,6 +254,7 @@ ustir_attach(device_t parent, device_t s DPRINTFN(10,("ustir_attach: sc=%p\n", sc)); sc->sc_dev = self; + sc->sc_init_state = USTIR_INIT_NONE; aprint_naive("\n"); aprint_normal("\n"); @@ -302,6 +307,7 @@ ustir_attach(device_t parent, device_t s sc->sc_child = config_found(self, , ir_print); selinit(>sc_rd_sel); selinit(>sc_wr_sel); + sc->sc_init_state = USTIR_INIT_INITED; return; } @@ -369,10 +375,12 @@ ustir_detach(device_t self, int flags) if (sc->sc_child != NULL) rv = config_detach(sc->sc_child, flags); - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); - - seldestroy(>sc_rd_sel); - seldestroy(>sc_wr_sel); + if (sc->sc_init_state >= USTIR_INIT_INITED) { + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); + seldestroy(>sc_rd_sel); + seldestroy(>sc_wr_sel); + } return rv; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:21:19 UTC 2019 Modified Files: src/sys/dev/usb: ustir.c Log Message: Fix error handling, to prevent kernel crashes at detach time. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/ustir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:19:52 UTC 2019 Modified Files: src/sys/dev/usb: uvisor.c Log Message: Fix possible NULL deref. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/uvisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 15:19:52 UTC 2019 Modified Files: src/sys/dev/usb: uvisor.c Log Message: Fix possible NULL deref. Found by vHCI. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/uvisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uvisor.c diff -u src/sys/dev/usb/uvisor.c:1.51 src/sys/dev/usb/uvisor.c:1.52 --- src/sys/dev/usb/uvisor.c:1.51 Thu May 9 02:43:35 2019 +++ src/sys/dev/usb/uvisor.c Sat Sep 14 15:19:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvisor.c,v 1.51 2019/05/09 02:43:35 mrg Exp $ */ +/* $NetBSD: uvisor.c,v 1.52 2019/09/14 15:19:52 maxv Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvisor.c,v 1.51 2019/05/09 02:43:35 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvisor.c,v 1.52 2019/09/14 15:19:52 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -404,8 +404,9 @@ uvisor_detach(device_t self, int flags) sc->sc_subdevs[i] = NULL; } } - - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + if (sc->sc_udev != NULL) + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); return rv; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:53:24 UTC 2019 Modified Files: src/sys/dev/usb: if_upgt.c if_upgtvar.h Log Message: Fix error handling, to prevent kernel crashes when detaching an upgt0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/if_upgt.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/if_upgtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_upgt.c diff -u src/sys/dev/usb/if_upgt.c:1.25 src/sys/dev/usb/if_upgt.c:1.26 --- src/sys/dev/usb/if_upgt.c:1.25 Wed Mar 6 08:08:25 2019 +++ src/sys/dev/usb/if_upgt.c Sat Sep 14 12:53:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_upgt.c,v 1.25 2019/03/06 08:08:25 msaitoh Exp $ */ +/* $NetBSD: if_upgt.c,v 1.26 2019/09/14 12:53:24 maxv Exp $ */ /* $OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.25 2019/03/06 08:08:25 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.26 2019/09/14 12:53:24 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -239,6 +239,7 @@ upgt_attach(device_t parent, device_t se */ sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; + sc->sc_init_state = UPGT_INIT_NONE; devinfop = usbd_devinfo_alloc(sc->sc_udev, 0); aprint_normal_dev(sc->sc_dev, "%s\n", devinfop); @@ -306,6 +307,7 @@ upgt_attach(device_t parent, device_t se callout_setfunc(>scan_to, upgt_next_scan, sc); callout_init(>led_to, 0); callout_setfunc(>led_to, upgt_set_led_blink, sc); + sc->sc_init_state = UPGT_INIT_INITED; /* * Open TX and RX USB bulk pipes. @@ -498,6 +500,9 @@ upgt_detach(device_t self, int flags) DPRINTF(1, "%s: %s\n", device_xname(sc->sc_dev), __func__); + if (sc->sc_init_state < UPGT_INIT_INITED) + return 0; + s = splnet(); if (ifp->if_flags & IFF_RUNNING) Index: src/sys/dev/usb/if_upgtvar.h diff -u src/sys/dev/usb/if_upgtvar.h:1.2 src/sys/dev/usb/if_upgtvar.h:1.3 --- src/sys/dev/usb/if_upgtvar.h:1.2 Sat Apr 23 10:15:31 2016 +++ src/sys/dev/usb/if_upgtvar.h Sat Sep 14 12:53:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_upgtvar.h,v 1.2 2016/04/23 10:15:31 skrll Exp $ */ +/* $NetBSD: if_upgtvar.h,v 1.3 2019/09/14 12:53:24 maxv Exp $ */ /* $OpenBSD: if_upgtvar.h,v 1.15 2009/08/10 20:02:19 deraadt Exp $ */ /* @@ -398,6 +398,10 @@ struct upgt_softc { struct ethercom sc_ec; #define sc_if sc_ec.ec_if + enum { + UPGT_INIT_NONE, + UPGT_INIT_INITED + } sc_init_state; struct usbd_device * sc_udev; struct usbd_interface * sc_iface; int sc_rx_no;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:53:24 UTC 2019 Modified Files: src/sys/dev/usb: if_upgt.c if_upgtvar.h Log Message: Fix error handling, to prevent kernel crashes when detaching an upgt0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/if_upgt.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/if_upgtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:50:16 UTC 2019 Modified Files: src/sys/dev/usb: udsbr.c Log Message: Fix NULL deref, to prevent kernel crashes when detaching an udsbr0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/usb/udsbr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:50:16 UTC 2019 Modified Files: src/sys/dev/usb: udsbr.c Log Message: Fix NULL deref, to prevent kernel crashes when detaching an udsbr0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/usb/udsbr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/udsbr.c diff -u src/sys/dev/usb/udsbr.c:1.27 src/sys/dev/usb/udsbr.c:1.28 --- src/sys/dev/usb/udsbr.c:1.27 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/udsbr.c Sat Sep 14 12:50:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: udsbr.c,v 1.27 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: udsbr.c,v 1.28 2019/09/14 12:50:16 maxv Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.27 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.28 2019/09/14 12:50:16 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -174,8 +174,9 @@ udsbr_detach(device_t self, int flags) if (sc->sc_child != NULL) rv = config_detach(sc->sc_child, flags); - - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + if (sc->sc_udev != NULL) + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); return rv; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:48:51 UTC 2019 Modified Files: src/sys/dev/usb: ugensa.c Log Message: Fix error handling, to prevent kernel crashes when detaching an ugensa0 device. Also move usbd_add_drv_event() down, after we are sure the attach didn't fail. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/ugensa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ugensa.c diff -u src/sys/dev/usb/ugensa.c:1.39 src/sys/dev/usb/ugensa.c:1.40 --- src/sys/dev/usb/ugensa.c:1.39 Thu May 9 02:43:35 2019 +++ src/sys/dev/usb/ugensa.c Sat Sep 14 12:48:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ugensa.c,v 1.39 2019/05/09 02:43:35 mrg Exp $ */ +/* $NetBSD: ugensa.c,v 1.40 2019/09/14 12:48:51 maxv Exp $ */ /* * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ugensa.c,v 1.39 2019/05/09 02:43:35 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugensa.c,v 1.40 2019/09/14 12:48:51 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -62,6 +62,12 @@ int ugensadebug = 0; struct ugensa_softc { device_t sc_dev; /* base device */ + + enum { + UGENSA_INIT_NONE, + UGENSA_INIT_INITED + } sc_init_state; + struct usbd_device * sc_udev; /* device */ struct usbd_interface * sc_iface; /* interface */ @@ -144,6 +150,7 @@ ugensa_attach(device_t parent, device_t sc->sc_dev = self; sc->sc_dying = false; + sc->sc_init_state = UGENSA_INIT_NONE; aprint_naive("\n"); aprint_normal("\n"); @@ -187,8 +194,6 @@ ugensa_attach(device_t parent, device_t ucaa.ucaa_methods = _methods; ucaa.ucaa_arg = sc; - usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); - ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1; for (i = 0; i < id->bNumEndpoints; i++) { int addr, dir, attr; @@ -227,6 +232,9 @@ ugensa_attach(device_t parent, device_t goto bad; } + sc->sc_init_state = UGENSA_INIT_INITED; + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); + DPRINTF(("ugensa: in=0x%x out=0x%x\n", ucaa.ucaa_bulkin, ucaa.ucaa_bulkout)); sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, , @@ -261,6 +269,9 @@ ugensa_detach(device_t self, int flags) sc->sc_dying = true; + if (sc->sc_init_state < UGENSA_INIT_INITED) + return 0; + if (sc->sc_subdev != NULL) { rv = config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:48:51 UTC 2019 Modified Files: src/sys/dev/usb: ugensa.c Log Message: Fix error handling, to prevent kernel crashes when detaching an ugensa0 device. Also move usbd_add_drv_event() down, after we are sure the attach didn't fail. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/ugensa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:46:00 UTC 2019 Modified Files: src/sys/dev/usb: uipaq.c Log Message: Fix NULL deref, to prevent kernel crashes when detaching an uipaq0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/uipaq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:46:00 UTC 2019 Modified Files: src/sys/dev/usb: uipaq.c Log Message: Fix NULL deref, to prevent kernel crashes when detaching an uipaq0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/uipaq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uipaq.c diff -u src/sys/dev/usb/uipaq.c:1.25 src/sys/dev/usb/uipaq.c:1.26 --- src/sys/dev/usb/uipaq.c:1.25 Thu May 9 02:43:35 2019 +++ src/sys/dev/usb/uipaq.c Sat Sep 14 12:46:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uipaq.c,v 1.25 2019/05/09 02:43:35 mrg Exp $ */ +/* $NetBSD: uipaq.c,v 1.26 2019/09/14 12:46:00 maxv Exp $ */ /* $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $ */ /* @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.25 2019/05/09 02:43:35 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.26 2019/09/14 12:46:00 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -398,8 +398,9 @@ uipaq_detach(device_t self, int flags) rv |= config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } - - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + if (sc->sc_udev != NULL) + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + sc->sc_dev); return rv; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:42:36 UTC 2019 Modified Files: src/sys/dev/usb: if_ural.c if_uralvar.h Log Message: Fix error handling, to prevent kernel crashes when detaching an ural0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/dev/usb/if_ural.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/usb/if_uralvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:42:36 UTC 2019 Modified Files: src/sys/dev/usb: if_ural.c if_uralvar.h Log Message: Fix error handling, to prevent kernel crashes when detaching an ural0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/dev/usb/if_ural.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/usb/if_uralvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_ural.c diff -u src/sys/dev/usb/if_ural.c:1.59 src/sys/dev/usb/if_ural.c:1.60 --- src/sys/dev/usb/if_ural.c:1.59 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/if_ural.c Sat Sep 14 12:42:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ural.c,v 1.59 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: if_ural.c,v 1.60 2019/09/14 12:42:36 maxv Exp $ */ /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */ /*- @@ -24,7 +24,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.59 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.60 2019/09/14 12:42:36 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -367,6 +367,7 @@ ural_attach(device_t parent, device_t se sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; + sc->sc_init_state = URAL_INIT_NONE; aprint_naive("\n"); aprint_normal("\n"); @@ -513,6 +514,8 @@ ural_attach(device_t parent, device_t se ieee80211_announce(ic); + sc->sc_init_state = URAL_INIT_INITED; + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); if (!pmf_device_register(self, NULL, NULL)) @@ -529,6 +532,9 @@ ural_detach(device_t self, int flags) struct ifnet *ifp = >sc_if; int s; + if (sc->sc_init_state < URAL_INIT_INITED) + return 0; + pmf_device_deregister(self); s = splusb(); Index: src/sys/dev/usb/if_uralvar.h diff -u src/sys/dev/usb/if_uralvar.h:1.12 src/sys/dev/usb/if_uralvar.h:1.13 --- src/sys/dev/usb/if_uralvar.h:1.12 Sat Apr 23 10:15:31 2016 +++ src/sys/dev/usb/if_uralvar.h Sat Sep 14 12:42:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_uralvar.h,v 1.12 2016/04/23 10:15:31 skrll Exp $ */ +/* $NetBSD: if_uralvar.h,v 1.13 2019/09/14 12:42:36 maxv Exp $ */ /* $OpenBSD: if_ralvar.h,v 1.2 2005/05/13 18:42:50 damien Exp $ */ /*- @@ -74,6 +74,11 @@ struct ural_softc { device_t sc_dev; struct ethercom sc_ec; #define sc_if sc_ec.ec_if + + enum { + URAL_INIT_NONE, + URAL_INIT_INITED + } sc_init_state; struct ieee80211com sc_ic; int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:41:32 UTC 2019 Modified Files: src/sys/dev/usb: urio.c Log Message: Fix error handling, to prevent kernel crashes when detaching an urio0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/dev/usb/urio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:41:32 UTC 2019 Modified Files: src/sys/dev/usb: urio.c Log Message: Fix error handling, to prevent kernel crashes when detaching an urio0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/dev/usb/urio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/urio.c diff -u src/sys/dev/usb/urio.c:1.48 src/sys/dev/usb/urio.c:1.49 --- src/sys/dev/usb/urio.c:1.48 Sun May 5 03:17:54 2019 +++ src/sys/dev/usb/urio.c Sat Sep 14 12:41:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: urio.c,v 1.48 2019/05/05 03:17:54 mrg Exp $ */ +/* $NetBSD: urio.c,v 1.49 2019/09/14 12:41:32 maxv Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: urio.c,v 1.48 2019/05/05 03:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: urio.c,v 1.49 2019/09/14 12:41:32 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -106,6 +106,10 @@ struct urio_softc { device_t sc_dev; struct usbd_device * sc_udev; struct usbd_interface * sc_iface; + enum { + URIO_INIT_NONE, + URIO_INIT_INITED + } sc_init_state; int sc_in_addr; struct usbd_pipe * sc_in_pipe; @@ -163,6 +167,7 @@ urio_attach(device_t parent, device_t se DPRINTFN(10,("urio_attach: sc=%p\n", sc)); sc->sc_dev = self; + sc->sc_init_state = URIO_INIT_NONE; aprint_naive("\n"); aprint_normal("\n"); @@ -215,6 +220,8 @@ urio_attach(device_t parent, device_t se usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); + sc->sc_init_state = URIO_INIT_INITED; + return; } @@ -254,6 +261,9 @@ urio_detach(device_t self, int flags) mn = device_unit(self); vdevgone(maj, mn, mn, VCHR); + if (sc->sc_init_state < URIO_INIT_INITED) + return 0; + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); return 0;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:40:31 UTC 2019 Modified Files: src/sys/dev/usb: if_urtw.c if_urtwreg.h Log Message: Fix error handling, to prevent kernel crashes when detaching an urtw0 device. Also, fail safely if we didn't recognize the RF chip, to prevent kernel crashes at attach time. Note that other panics are there, maybe they also should be removed. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/if_urtw.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/if_urtwreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:40:31 UTC 2019 Modified Files: src/sys/dev/usb: if_urtw.c if_urtwreg.h Log Message: Fix error handling, to prevent kernel crashes when detaching an urtw0 device. Also, fail safely if we didn't recognize the RF chip, to prevent kernel crashes at attach time. Note that other panics are there, maybe they also should be removed. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/if_urtw.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/if_urtwreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urtw.c diff -u src/sys/dev/usb/if_urtw.c:1.18 src/sys/dev/usb/if_urtw.c:1.19 --- src/sys/dev/usb/if_urtw.c:1.18 Wed Sep 12 21:57:18 2018 +++ src/sys/dev/usb/if_urtw.c Sat Sep 14 12:40:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtw.c,v 1.18 2018/09/12 21:57:18 christos Exp $ */ +/* $NetBSD: if_urtw.c,v 1.19 2019/09/14 12:40:31 maxv Exp $ */ /* $OpenBSD: if_urtw.c,v 1.39 2011/07/03 15:47:17 matthew Exp $ */ /*- @@ -19,7 +19,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.18 2018/09/12 21:57:18 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.19 2019/09/14 12:40:31 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -614,6 +614,7 @@ urtw_attach(device_t parent, device_t se sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; sc->sc_hwrev = urtw_lookup(uaa->uaa_vendor, uaa->uaa_product)->rev; + sc->sc_init_state = URTW_INIT_NONE; aprint_naive("\n"); aprint_normal(": "); @@ -757,6 +758,8 @@ urtw_attach(device_t parent, device_t se ieee80211_announce(ic); + sc->sc_init_state = URTW_INIT_INITED; + return; fail: aprint_error(": %s failed!\n", __func__); @@ -774,6 +777,9 @@ urtw_detach(device_t self, int flags) sc->sc_dying = true; + if (sc->sc_init_state < URTW_INIT_INITED) + goto out; + callout_halt(>scan_to, NULL); callout_halt(>sc_led_ch, NULL); callout_destroy(>scan_to); @@ -794,8 +800,8 @@ urtw_detach(device_t self, int flags) urtw_free_rx_data_list(sc); urtw_close_pipes(sc); +out: splx(s); - return 0; } @@ -1279,8 +1285,7 @@ urtw_get_rfchip(struct urtw_softc *sc) if (sc->sc_hwrev & URTW_HWREV_8187) { error = urtw_eprom_read32(sc, URTW_EPROM_RFCHIPID, ); if (error != 0) - panic("unsupported RF chip"); - /* NOTREACHED */ + return error; switch (data & 0xff) { case URTW_EPROM_RFCHIPID_RTL8225U: error = urtw_8225_isv2(sc, ); @@ -1313,8 +1318,8 @@ urtw_get_rfchip(struct urtw_softc *sc) return 0; fail: - panic("unsupported RF chip %d", data & 0xff); - /* NOTREACHED */ + aprint_error(": unsupported RF chip %d", data & 0xff); + return USBD_INVAL; } usbd_status Index: src/sys/dev/usb/if_urtwreg.h diff -u src/sys/dev/usb/if_urtwreg.h:1.2 src/sys/dev/usb/if_urtwreg.h:1.3 --- src/sys/dev/usb/if_urtwreg.h:1.2 Sat Apr 23 10:15:32 2016 +++ src/sys/dev/usb/if_urtwreg.h Sat Sep 14 12:40:31 2019 @@ -323,6 +323,11 @@ struct urtw_softc { struct ieee80211com sc_ic; struct ethercom sc_ec; #define sc_if sc_ec.ec_if + + enum { + URTW_INIT_NONE, + URTW_INIT_INITED + } sc_init_state; int(*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int); struct urtw_rf sc_rf;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: maxv Date: Sat Sep 14 12:38:40 UTC 2019 Modified Files: src/sys/dev/usb: umcs.c Log Message: Fix error handling, to prevent kernel crashes when detaching an umcs0 device. Found with vHCI. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/usb/umcs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umcs.c diff -u src/sys/dev/usb/umcs.c:1.13 src/sys/dev/usb/umcs.c:1.14 --- src/sys/dev/usb/umcs.c:1.13 Thu May 9 02:43:35 2019 +++ src/sys/dev/usb/umcs.c Sat Sep 14 12:38:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: umcs.c,v 1.13 2019/05/09 02:43:35 mrg Exp $ */ +/* $NetBSD: umcs.c,v 1.14 2019/09/14 12:38:40 maxv Exp $ */ /* $FreeBSD: head/sys/dev/usb/serial/umcs.c 260559 2014-01-12 11:44:28Z hselasky $ */ /*- @@ -41,7 +41,7 @@ * */ #include -__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.13 2019/05/09 02:43:35 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.14 2019/09/14 12:38:40 maxv Exp $"); #include #include @@ -85,6 +85,10 @@ struct umcs7840_softc_oneport { struct umcs7840_softc { device_t sc_dev; /* ourself */ + enum { + UMCS_INIT_NONE, + UMCS_INIT_INITED + } sc_init_state; struct usbd_interface *sc_iface; /* the usb interface */ struct usbd_device *sc_udev; /* the usb device */ struct usbd_pipe *sc_intr_pipe; /* interrupt pipe */ @@ -193,6 +197,7 @@ umcs7840_attach(device_t parent, device_ sc->sc_dev = self; sc->sc_udev = uaa->uaa_device; sc->sc_dying = false; + sc->sc_init_state = UMCS_INIT_NONE; if (usbd_set_config_index(sc->sc_udev, MCS7840_CONFIG_INDEX, 1) != 0) { aprint_error(": could not set configuration no\n"); @@ -288,6 +293,8 @@ umcs7840_attach(device_t parent, device_ usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); + sc->sc_init_state = UMCS_INIT_INITED; + memset(, 0, sizeof(ucaa)); ucaa.ucaa_ibufsize = 256; ucaa.ucaa_obufsize = 256; @@ -517,6 +524,10 @@ umcs7840_detach(device_t self, int flags kmem_free(sc->sc_intr_buf, sc->sc_intr_buflen); sc->sc_intr_buf = NULL; } + + if (sc->sc_init_state < UMCS_INIT_INITED) + return 0; + usb_rem_task_wait(sc->sc_udev, >sc_change_task, USB_TASKQ_DRIVER, NULL);