Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb bus_dmamem_alloc may change the number of reques...



details:   https://anonhg.NetBSD.org/src/rev/98a946c5fca5
branches:  trunk
changeset: 784285:98a946c5fca5
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Jan 23 23:44:30 2013 +0000

description:
bus_dmamem_alloc may change the number of requested segs, so keep the number requested for kmem_free use later

diffstat:

 sys/dev/usb/usb_mem.c |  9 +++++----
 sys/dev/usb/usb_mem.h |  3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diffs (61 lines):

diff -r 1849321de527 -r 98a946c5fca5 sys/dev/usb/usb_mem.c
--- a/sys/dev/usb/usb_mem.c     Wed Jan 23 23:31:26 2013 +0000
+++ b/sys/dev/usb/usb_mem.c     Wed Jan 23 23:44:30 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.c,v 1.58 2013/01/19 20:49:33 christos Exp $    */
+/*     $NetBSD: usb_mem.c,v 1.59 2013/01/23 23:44:30 jmcneill Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.58 2013/01/19 20:49:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.59 2013/01/23 23:44:30 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -178,6 +178,7 @@
                kmem_free(b, sizeof *b);
                return USBD_NOMEM;
        }
+       b->nsegs_alloc = b->nsegs;
 
        error = bus_dmamem_alloc(tag, b->size, align, 0,
                                 b->segs, b->nsegs,
@@ -214,7 +215,7 @@
  free1:
        bus_dmamem_free(tag, b->segs, b->nsegs);
  free0:
-       kmem_free(b->segs, b->nsegs * sizeof(*b->segs));
+       kmem_free(b->segs, b->nsegs_alloc * sizeof(*b->segs));
        kmem_free(b, sizeof *b);
        return (USBD_NOMEM);
 }
@@ -233,7 +234,7 @@
        bus_dmamap_destroy(b->tag, b->map);
        bus_dmamem_unmap(b->tag, b->kaddr, b->size);
        bus_dmamem_free(b->tag, b->segs, b->nsegs);
-       kmem_free(b->segs, b->nsegs * sizeof(*b->segs));
+       kmem_free(b->segs, b->nsegs_alloc * sizeof(*b->segs));
        kmem_free(b, sizeof *b);
 }
 #endif
diff -r 1849321de527 -r 98a946c5fca5 sys/dev/usb/usb_mem.h
--- a/sys/dev/usb/usb_mem.h     Wed Jan 23 23:31:26 2013 +0000
+++ b/sys/dev/usb/usb_mem.h     Wed Jan 23 23:44:30 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.h,v 1.29 2013/01/07 15:07:41 prlw1 Exp $       */
+/*     $NetBSD: usb_mem.h,v 1.30 2013/01/23 23:44:30 jmcneill Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $     */
 
 /*
@@ -37,6 +37,7 @@
         void *kaddr;
         bus_dma_segment_t *segs;
         int nsegs;
+        int nsegs_alloc;
         size_t size;
         size_t align;
        int flags;



Home | Main Index | Thread Index | Old Index