Module Name: src
Committed By: riastradh
Date: Wed May 22 15:59:25 UTC 2024
Modified Files:
src/sys/external/bsd/drm2/linux: linux_xa.c
Log Message:
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_xa.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/linux/linux_xa.c
diff -u src/sys/external/bsd/drm2/linux/linux_xa.c:1.3 src/sys/external/bsd/drm2/linux/linux_xa.c:1.4
--- src/sys/external/bsd/drm2/linux/linux_xa.c:1.3 Sun Dec 19 12:05:25 2021
+++ src/sys/external/bsd/drm2/linux/linux_xa.c Wed May 22 15:59:25 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $ */
+/* $NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $");
/*
* This is a lame-o implementation of the Linux xarray data type, which
@@ -124,7 +124,7 @@ xa_load(struct xarray *xa, unsigned long
void *
xa_store(struct xarray *xa, unsigned long key, void *datum, gfp_t gfp)
{
- struct node *n, *collision;
+ struct node *n, *collision, *recollision;
KASSERT(datum != NULL);
KASSERT(((uintptr_t)datum & 0x3) == 0);
@@ -137,6 +137,11 @@ xa_store(struct xarray *xa, unsigned lon
mutex_enter(&xa->xa_lock);
collision = rb_tree_insert_node(&xa->xa_tree, n);
+ if (collision != n) {
+ rb_tree_remove_node(&xa->xa_tree, n);
+ recollision = rb_tree_insert_node(&xa->xa_tree, n);
+ KASSERT(recollision == n);
+ }
mutex_exit(&xa->xa_lock);
if (collision != n) {