From: Peter Senna Tschudin <peter.senna@linux.intel.com>
To: "Manszewski, Christoph" <christoph.manszewski@intel.com>,
igt-dev@lists.freedesktop.org,
Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: Re: [PATCH i-g-t] lib/igt_list: igt_list_empty() Detect uninitialized list
Date: Tue, 23 Sep 2025 11:20:13 +0200 [thread overview]
Message-ID: <f750c914-c68e-4fe6-9ecd-9cf1731c502e@linux.intel.com> (raw)
In-Reply-To: <0a1dc4a1-a910-43c5-b078-4e9cf3cc3f91@intel.com>
Hi Christoph,
On 9/23/2025 10:14 AM, Manszewski, Christoph wrote:
> Hi Peter,
>
> On 22.09.2025 18:23, Peter Senna Tschudin wrote:
>> 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;
>> +
>
> Without this change:
> 1. Passing an uninitialized list is a bug
> 2. The function doesn't check any condition and returns 'normally'
> regardless
>
> With this change:
> 1. Passing an uninitialized list is a bug (still)
> 2. The function *may* detect an uninitialized list which is a bug but
> returns 'normally' regardless
>
> If we are adding a check that catches some invalid/buggy condition the
> reasonable thing to do would be to assert/abort.
I agree with you. I would say that even more concerning is to distance
our implementation from the kernel implementation. I suggest we nack
this change. If you are ok with it
Nacked-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
>
> Regards,
> Christoph
>
>
>> return head->next == head;
>> }
>
next prev parent reply other threads:[~2025-09-23 9:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-09-23 9:32 ` Manszewski, Christoph
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f750c914-c68e-4fe6-9ecd-9cf1731c502e@linux.intel.com \
--to=peter.senna@linux.intel.com \
--cc=christoph.manszewski@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox