Source-Changes-HG archive

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

[src/riastradh-drm2]: src/sys/external/bsd/drm2/drm Fix sense of refcount dec...



details:   https://anonhg.NetBSD.org/src/rev/02e42c5fc44a
branches:  riastradh-drm2
changeset: 788277:02e42c5fc44a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 03:02:21 2013 +0000

description:
Fix sense of refcount decrement conditional in drm_iounmap.

Add some kasserts just in case.

diffstat:

 sys/external/bsd/drm2/drm/drm_memory.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (61 lines):

diff -r 11b887db5e13 -r 02e42c5fc44a sys/external/bsd/drm2/drm/drm_memory.c
--- a/sys/external/bsd/drm2/drm/drm_memory.c    Wed Jul 24 03:02:07 2013 +0000
+++ b/sys/external/bsd/drm2/drm/drm_memory.c    Wed Jul 24 03:02:21 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_memory.c,v 1.1.2.4 2013/07/24 02:47:50 riastradh Exp $     */
+/*     $NetBSD: drm_memory.c,v 1.1.2.5 2013/07/24 03:02:21 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_memory.c,v 1.1.2.4 2013/07/24 02:47:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_memory.c,v 1.1.2.5 2013/07/24 03:02:21 riastradh Exp $");
 
 /* XXX Cargo-culted from the old drm_memory.c.  */
 
@@ -121,6 +121,8 @@
                }
 
                /* Mark it used and make a subregion just for the request.  */
+               if (bm->bm_mapped == UINT_MAX)
+                       return NULL;
                bm->bm_mapped++;
                error = bus_space_subregion(bst, bm->bm_bsh,
                    map->offset - bm->bm_base, map->size,
@@ -130,6 +132,7 @@
                         * Back out: unmark it and, if nobody else was
                         * using it, unmap it.
                         */
+                       KASSERT(bm->bm_mapped > 0);
                        if (--bm->bm_mapped == 0)
                                bus_space_unmap(bst, bm->bm_bsh,
                                    bm->bm_size);
@@ -166,6 +169,8 @@
                                continue;
 
                        /* Mark it used and return it.  */
+                       if (bm->bm_mapped == UINT_MAX)
+                               return NULL;
                        bm->bm_mapped++;
 
                        /* XXX size is an input/output parameter too...?  */
@@ -185,6 +190,7 @@
                                return NULL; /* XXX Why not continue?  */
 
                        /* Got it.  Allocate this bus map.  */
+                       KASSERT(bm->bm_mapped == 0);
                        bm->bm_mapped++;
                        bm->bm_base = map->offset;
                        bm->bm_size = map->size;
@@ -215,7 +221,7 @@
         */
        if (bm != NULL) {
                KASSERT(bm->bm_mapped > 0);
-               if (--bm->bm_mapped)
+               if (--bm->bm_mapped == 0)
                        bus_space_unmap(bst, bm->bm_bsh, bm->bm_size);
        }
 }



Home | Main Index | Thread Index | Old Index