mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] DRM: Fix rbtree search issue of find_hole_addr
@ 2025-05-23  8:39 junan
  0 siblings, 0 replies; only message in thread
From: junan @ 2025-05-23  8:39 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, airlied, simona, tzimmermann
  Cc: dri-devel, linux-kernel, junan76

I'm not sure if it is a bug or just for some special purposes in the function
"find_hole_addr", the original implementation is as follows:

static struct drm_mm_node *find_hole_addr(struct drm_mm *mm, u64 addr, u64 size)
{
	struct rb_node *rb = mm->holes_addr.rb_node;
	struct drm_mm_node *node = NULL;

	while (rb) {
		u64 hole_start;

		if (!usable_hole_addr(rb, size))
			break;

		node = rb_hole_addr_to_node(rb);
		hole_start = __drm_mm_hole_node_start(node);

		if (addr < hole_start)
			rb = node->rb_hole_addr.rb_left;
		else if (addr > hole_start + node->hole_size)
			rb = node->rb_hole_addr.rb_right;
		else
			break;

	}

	return node;
}

I think that the "node" should be set to NULL if it is not the one we want,
please tell me if I am wrong.

Signed-off-by: junan <junan76@163.com>
---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index ca254611b382..9417911198b5 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -347,6 +347,8 @@ static struct drm_mm_node *find_hole_addr(struct drm_mm *mm, u64 addr, u64 size)
 			rb = node->rb_hole_addr.rb_right;
 		else
 			break;
+
+		node = NULL;
 	}
 
 	return node;
-- 
2.43.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-05-23  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-23  8:39 [PATCH] DRM: Fix rbtree search issue of find_hole_addr junan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®