lkml.org 
[lkml]   [2022]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] firewire: remove check of list iterator against head past the loop body
Hi,

On Fri, Apr 01, 2022 at 12:36:01AM +0200, Jakob Koschel wrote:
> When list_for_each_entry() completes the iteration over the whole list
> without breaking the loop, the iterator value will be a bogus pointer
> computed based on the head element.
>
> While it is safe to use the pointer to determine if it was computed
> based on the head element, either with list_entry_is_head() or
> &pos->member == head, using the iterator variable after the loop should
> be avoided.
>
> In preparation to limit the scope of a list iterator to the list
> traversal loop, use a dedicated pointer to point to the found element [1].
>
> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
> ---
> drivers/firewire/core-transaction.c | 30 +++++++++++++++--------------
> drivers/firewire/sbp2.c | 13 +++++++------
> 2 files changed, 23 insertions(+), 20 deletions(-)

I think it is a good catch.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

For the changes in firewire-core module:
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Unfortunately the activity for maintenance in Linux FireWire subsystem
is quite low. No actions in past half a year. If the patch blocks
further work to improve list implementation, I think it better to look
for the other path to merge.


Regards

Takashi Sakamoto

\
 
 \ /
  Last update: 2022-04-03 07:04    [W:2.670 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site