Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_list: igt_list_empty() Detect uninitialized list
@ 2025-09-22 16:23 Peter Senna Tschudin
  2025-09-22 19:49 ` ✓ Xe.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-09-22 16:23 UTC (permalink / raw)
  To: igt-dev; +Cc: Peter Senna Tschudin

Add a check to igt_list_empty() to return true if the list head pointer
or its next/prev pointers are NULL, preventing segfaults when operating
on uninitialized or potentially broken lists.

Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
 lib/igt_list.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/igt_list.c b/lib/igt_list.c
index 37ae139c4..f77aef7dd 100644
--- a/lib/igt_list.c
+++ b/lib/igt_list.c
@@ -79,5 +79,9 @@ int igt_list_length(const struct igt_list_head *head)
 
 bool igt_list_empty(const struct igt_list_head *head)
 {
+	/* Detect uninitialized / potentially broken list */
+	if (!head || !head->next || !head->prev)
+		return true;
+
 	return head->next == head;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-23  9:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 16:23 [PATCH i-g-t] lib/igt_list: igt_list_empty() Detect uninitialized list Peter Senna Tschudin
2025-09-22 19:49 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-09-22 19:56 ` ✗ i915.CI.BAT: failure " Patchwork
2025-09-23  1:16 ` ✓ Xe.CI.Full: success " Patchwork
2025-09-23  8:14 ` [PATCH i-g-t] " Manszewski, Christoph
2025-09-23  9:20   ` Peter Senna Tschudin
2025-09-23  9:32     ` Manszewski, Christoph

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