diff options
| author | 2011-09-29 11:18:01 +0000 | |
|---|---|---|
| committer | 2011-09-29 11:18:01 +0000 | |
| commit | 8a31dd35831372a2ea3818c33813761b0c79c901 (patch) | |
| tree | ed47e8db68522f850901e260c95e3302adddaaed /sys/dev/usb/uhub.c | |
| parent | Add -S option to refresh-client to redraw status line, from Marco Beck. (diff) | |
| download | wireguard-openbsd-8a31dd35831372a2ea3818c33813761b0c79c901.tar.xz wireguard-openbsd-8a31dd35831372a2ea3818c33813761b0c79c901.zip | |
Avoid a potential NULL dereference if nports == 0.
Found by Amit Kulkarni using clang.
Fix from jakemsr; his diff was sitting on tech@ since February.
ok myself, phessler, sthen, jasper
and also pirofti, mikeb, krw (back in February)
Diffstat (limited to 'sys/dev/usb/uhub.c')
| -rw-r--r-- | sys/dev/usb/uhub.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 0da6613206f..04130e7001b 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhub.c,v 1.58 2011/07/03 15:47:17 matthew Exp $ */ +/* $OpenBSD: uhub.c,v 1.59 2011/09/29 11:18:01 stsp Exp $ */ /* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ @@ -331,10 +331,11 @@ uhub_attach(struct device *parent, struct device *self, void *aux) bad: if (sc->sc_statusbuf) free(sc->sc_statusbuf, M_USBDEV); - if (hub->ports) - free(hub->ports, M_USBDEV); - if (hub) + if (hub) { + if (hub->ports) + free(hub->ports, M_USBDEV); free(hub, M_USBDEV); + } dev->hub = NULL; } |
