summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/uhub.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-11-10 15:29:22 +0000
committermpi <mpi@openbsd.org>2018-11-10 15:29:22 +0000
commitbd50d633efded32fc1dce790e427471bd4a9ae41 (patch)
treecadbb64f15c207467f69e9e134e0cf513cdce2f5 /sys/dev/usb/uhub.c
parentPass free(9) sizes for the tx descriptors. (diff)
downloadwireguard-openbsd-bd50d633efded32fc1dce790e427471bd4a9ae41.tar.xz
wireguard-openbsd-bd50d633efded32fc1dce790e427471bd4a9ae41.zip
Pass free(9) sizes for port arrays.
ok tedu@, visa@
Diffstat (limited to 'sys/dev/usb/uhub.c')
-rw-r--r--sys/dev/usb/uhub.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index afab99e7936..c4ee5c0f12a 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhub.c,v 1.90 2017/04/08 02:57:25 deraadt Exp $ */
+/* $OpenBSD: uhub.c,v 1.91 2018/11/10 15:29:22 mpi 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 $ */
@@ -292,7 +292,7 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
if (UHUB_IS_HIGH_SPEED(sc)) {
tts = mallocarray((UHUB_IS_SINGLE_TT(sc) ? 1 : nports),
- sizeof (struct usbd_tt), M_USBDEV, M_NOWAIT);
+ sizeof(struct usbd_tt), M_USBDEV, M_NOWAIT);
if (!tts)
goto bad;
}
@@ -339,12 +339,10 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
return;
bad:
- if (sc->sc_statusbuf)
- free(sc->sc_statusbuf, M_USBDEV, sc->sc_statuslen);
+ free(sc->sc_statusbuf, M_USBDEV, sc->sc_statuslen);
if (hub) {
- if (hub->ports)
- free(hub->ports, M_USBDEV, 0);
- free(hub, M_USBDEV, sizeof *hub);
+ free(hub->ports, M_USBDEV, hub->nports * sizeof(*hub->ports));
+ free(hub, M_USBDEV, sizeof(*hub));
}
dev->hub = NULL;
}
@@ -474,13 +472,11 @@ uhub_detach(struct device *self, int flags)
}
}
- if (hub->ports[0].tt)
- free(hub->ports[0].tt, M_USBDEV, 0);
- if (sc->sc_statusbuf)
- free(sc->sc_statusbuf, M_USBDEV, sc->sc_statuslen);
- if (hub->ports)
- free(hub->ports, M_USBDEV, 0);
- free(hub, M_USBDEV, sizeof *hub);
+ free(hub->ports[0].tt, M_USBDEV,
+ (UHUB_IS_SINGLE_TT(sc) ? 1 : hub->nports) * sizeof(struct usbd_tt));
+ free(sc->sc_statusbuf, M_USBDEV, sc->sc_statuslen);
+ free(hub->ports, M_USBDEV, hub->nports * sizeof(*hub->ports));
+ free(hub, M_USBDEV, sizeof(*hub));
sc->sc_hub->hub = NULL;
return (0);