lkml.org 
[lkml]   [2023]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next] net/mlx5e: avoid usage of list iterator after loop
On Mon, Mar 13, 2023 at 04:26:02PM +0100, Jakob Koschel wrote:
> If potentially no valid element is found, 'priv_rx' would contain an
> invalid pointer past the iterator loop. To ensure 'priv_rx' is always
> valid, we only set it if the correct element was found. That allows
> adding a WARN_ON() in case the code works incorrectly, exposing
> currently undetectable potential bugs.
>
> Additionally, Linus proposed to avoid any use of the list iterator
> variable after the loop, in the attempt to move the list iterator
> variable declaration into the macro to avoid any potential misuse after
> the loop [1].
>
> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
> Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

\
 
 \ /
  Last update: 2023-03-27 00:59    [W:0.056 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site