Module Name:    src
Committed By:   skrll
Date:           Sat Jan 21 07:39:31 UTC 2017

Modified Files:
        src/sys/dev/usb: xhci.c

Log Message:
Fix a kmem_{zalloc,free} size


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.69 src/sys/dev/usb/xhci.c:1.70
--- src/sys/dev/usb/xhci.c:1.69	Thu Jan 19 20:35:44 2017
+++ src/sys/dev/usb/xhci.c	Sat Jan 21 07:39:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.69 2017/01/19 20:35:44 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.70 2017/01/21 07:39:30 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.69 2017/01/19 20:35:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.70 2017/01/21 07:39:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -614,7 +614,8 @@ xhci_detach(struct xhci_softc *sc, int f
 
 	kmem_free(sc->sc_slots, sizeof(*sc->sc_slots) * sc->sc_maxslots);
 
-	kmem_free(sc->sc_ctlrportbus, sc->sc_maxports * sizeof(uint8_t) / NBBY);
+	kmem_free(sc->sc_ctlrportbus, 
+	    howmany(sc->sc_maxports * sizeof(uint8_t), NBBY));
 	kmem_free(sc->sc_ctlrportmap, sc->sc_maxports * sizeof(int));
 
 	for (size_t j = 0; j < __arraycount(sc->sc_rhportmap); j++) {
@@ -958,7 +959,8 @@ xhci_init(struct xhci_softc *sc)
 	aprint_debug_dev(sc->sc_dev, "xECP %x\n", XHCI_HCC_XECP(hcc) * 4);
 
 	/* default all ports to bus 0, i.e. usb 3 */
-	sc->sc_ctlrportbus = kmem_zalloc(sc->sc_maxports * sizeof(uint8_t) / NBBY, KM_SLEEP);
+	sc->sc_ctlrportbus = kmem_zalloc(
+	    howmany(sc->sc_maxports * sizeof(uint8_t), NBBY), KM_SLEEP);
 	sc->sc_ctlrportmap = kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
 
 	/* controller port to bus roothub port map */

Reply via email to