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 drm: dma_fence_get allows fence ...
details: https://anonhg.NetBSD.org/src/rev/2254cdfb60a9
branches: trunk
changeset: 1028861:2254cdfb60a9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 12:13:45 2021 +0000
description:
drm: dma_fence_get allows fence to be null; fix assertion.
While here, update comments about semantics for dma_fence_get and
dma_fence_get_rcu (which does not allow null fence).
diffstat:
sys/external/bsd/drm2/linux/linux_dma_fence.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diffs (53 lines):
diff -r 104dfca8674f -r 2254cdfb60a9 sys/external/bsd/drm2/linux/linux_dma_fence.c
--- a/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:13:37 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:13:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_dma_fence.c,v 1.25 2021/12/19 12:11:05 riastradh Exp $ */
+/* $NetBSD: linux_dma_fence.c,v 1.26 2021/12/19 12:13:45 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.25 2021/12/19 12:11:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.26 2021/12/19 12:13:45 riastradh Exp $");
#include <sys/atomic.h>
#include <sys/condvar.h>
@@ -246,18 +246,21 @@
/*
* dma_fence_get(fence)
*
- * Acquire a reference to fence. The fence must not be being
- * destroyed. Return the fence.
+ * Acquire a reference to fence and return it, or return NULL if
+ * fence is NULL. The fence, if nonnull, must not be being
+ * destroyed.
*/
struct dma_fence *
dma_fence_get(struct dma_fence *fence)
{
+ if (fence == NULL)
+ return NULL;
+
KASSERTMSG(fence->f_magic != FENCE_MAGIC_BAD, "fence %p", fence);
KASSERTMSG(fence->f_magic == FENCE_MAGIC_GOOD, "fence %p", fence);
- if (fence)
- kref_get(&fence->refcount);
+ kref_get(&fence->refcount);
return fence;
}
@@ -266,7 +269,7 @@
*
* Attempt to acquire a reference to a fence that may be about to
* be destroyed, during a read section. Return the fence on
- * success, or NULL on failure.
+ * success, or NULL on failure. The fence must be nonnull.
*/
struct dma_fence *
dma_fence_get_rcu(struct dma_fence *fence)
Home |
Main Index |
Thread Index |
Old Index