diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-09-29 11:18:02 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-09-29 11:18:02 +0000 |
commit | f8a3edc9fbb2a86ccc401ee5a036fe2caf59aaa1 (patch) | |
tree | ec10687f08d819a9e8de55763ee2154f80defe0e /sys/dev/usb | |
parent | b0924492332f92316c81dcc1d85768892586d82d (diff) |
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')
-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; } |