Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Fix a kmem_{zalloc,free} size



details:   https://anonhg.NetBSD.org/src/rev/737e2e3b4b8e
branches:  trunk
changeset: 821031:737e2e3b4b8e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Jan 21 07:39:30 2017 +0000

description:
Fix a kmem_{zalloc,free} size

diffstat:

 sys/dev/usb/xhci.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r ecb5af768552 -r 737e2e3b4b8e sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c        Sat Jan 21 05:58:49 2017 +0000
+++ b/sys/dev/usb/xhci.c        Sat Jan 21 07:39:30 2017 +0000
@@ -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 @@
 
        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 @@
        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 */



Home | Main Index | Thread Index | Old Index