Re: [PATCH v3 1/2] list: add missing empty list check to list_cut_before()
From: Andy Shevchenko
Date: Fri Sep 18 2026 - 05:50:51 EST
On Fri, Sep 18, 2026 at 04:10:25PM +0800, Ziran Zhang wrote:
> list_cut_before() lacks the list_empty() guard present in
> list_cut_position(). With an empty head, the function falls through
> to the pointer updates instead of returning early.
>
> Both helpers share the same kernel-doc wording:
>
> 'You should pass on @entry an element you know is on @head.'
>
> Nevertheless, list_cut_position() returns early for an empty head,
> and list_splice() also checks its source list before doing any
> pointer updates. Make list_cut_before() consistent with them for
> the empty-list case.
OK, the reasoning sounds good to me,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
--
With Best Regards,
Andy Shevchenko