Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2/linux There may not be an old list.



details:   https://anonhg.NetBSD.org/src/rev/08d4350b8419
branches:  trunk
changeset: 835329:08d4350b8419
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 14:13:46 2018 +0000

description:
There may not be an old list.

Nihil ex nihilo -- don't dereference null.

diffstat:

 sys/external/bsd/drm2/linux/linux_reservation.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (62 lines):

diff -r 49ee7e202ac5 -r 08d4350b8419 sys/external/bsd/drm2/linux/linux_reservation.c
--- a/sys/external/bsd/drm2/linux/linux_reservation.c   Mon Aug 27 14:13:29 2018 +0000
+++ b/sys/external/bsd/drm2/linux/linux_reservation.c   Mon Aug 27 14:13:46 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_reservation.c,v 1.5 2018/08/27 14:13:00 riastradh Exp $  */
+/*     $NetBSD: linux_reservation.c,v 1.6 2018/08/27 14:13:46 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.5 2018/08/27 14:13:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_reservation.c,v 1.6 2018/08/27 14:13:46 riastradh Exp $");
 
 #include <linux/fence.h>
 #include <linux/reservation.h>
@@ -411,13 +411,15 @@
                /* Commit the update.  */
                reservation_object_write_commit(robj, &ticket);
        } else {
-               KASSERT(list->shared_count < prealloc->shared_max);
+               uint32_t shared_count = (list == NULL? 0 : list->shared_count);
+
+               KASSERT(shared_count < prealloc->shared_max);
 
                /*
                 * Copy the fences over, but replace if we find one
                 * with the same context number.
                 */
-               for (i = 0; i < list->shared_count; i++) {
+               for (i = 0; i < shared_count; i++) {
                        if (replace == NULL &&
                            list->shared[i]->context == fence->context) {
                                replace = list->shared[i];
@@ -426,7 +428,7 @@
                                prealloc->shared[i] = list->shared[i];
                        }
                }
-               prealloc->shared_count = list->shared_count;
+               prealloc->shared_count = shared_count;
 
                /* If we didn't find one, add it at the end.  */
                if (replace == NULL)
@@ -443,11 +445,12 @@
                reservation_object_write_commit(robj, &ticket);
 
                /*
-                * Free the old list when it is convenient.  (We are
-                * not in a position at this point to sleep waiting for
-                * activity on all CPUs.)
+                * If there is an old list, free it when convenient.
+                * (We are not in a position at this point to sleep
+                * waiting for activity on all CPUs.)
                 */
-               objlist_defer_free(list);
+               if (list != NULL)
+                       objlist_defer_free(list);
        }
 
        /* Release a fence if we replaced it.  */



Home | Main Index | Thread Index | Old Index