All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Manszewski, Christoph" <christoph.manszewski@intel.com>
To: Peter Senna Tschudin <peter.senna@linux.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:32:50 +0200	[thread overview]
Message-ID: <00a31b63-b1ae-43cc-9679-3c307fcdc7a0@intel.com> (raw)
In-Reply-To: <f750c914-c68e-4fe6-9ecd-9cf1731c502e@linux.intel.com>

Hi Peter,

On 23.09.2025 11:20, Peter Senna Tschudin wrote:
> 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

Well either way is fine with by me. I just wanted to make a point that 
when we add a check that catches a bug it makes sense to alarm the 
developer right away.

Regards,
Christoph

> 
> Nacked-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
> 
>>
>> Regards,
>> Christoph
>>
>>
>>>        return head->next == head;
>>>    }
>>
> 


      reply	other threads:[~2025-09-23  9:32 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
2025-09-23  9:32     ` Manszewski, Christoph [this message]

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=00a31b63-b1ae-43cc-9679-3c307fcdc7a0@intel.com \
    --to=christoph.manszewski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=peter.senna@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.