[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+vzHO3yferPBi1kBmVkRAd1mu9gD0S8tUPdVaDXapkVw@mail.gmail.com>
Date: Thu, 24 Jul 2025 04:18:09 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Pengtao He <hept.hept.hept@...il.com>
Cc: "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Willem de Bruijn <willemb@...gle.com>, Mina Almasry <almasrymina@...gle.com>,
Jason Xing <kerneljasonxing@...il.com>, Michal Luczaj <mhal@...x.co>,
Eric Biggers <ebiggers@...gle.com>, Alexander Lobakin <aleksander.lobakin@...el.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2] net/core: fix wrong return value in __splice_segment
On Thu, Jul 24, 2025 at 3:29 AM Pengtao He <hept.hept.hept@...il.com> wrote:
>
> Return true immediately when the last segment is processed,
> avoid to walking once more in the frags loop.
>
> Signed-off-by: Pengtao He <hept.hept.hept@...il.com>
> ---
> v2->v1:
> Correct the commit message and target tree.
> v1:
> https://lore.kernel.org/netdev/20250723063119.24059-1-hept.hept.hept@gmail.com/
> ---
> net/core/skbuff.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index ee0274417948..cc3339ab829a 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3114,6 +3114,9 @@ static bool __splice_segment(struct page *page, unsigned int poff,
> *len -= flen;
> } while (*len && plen);
>
> + if (!*len)
> + return true;
> +
> return false;
> }
>
Condition is evaluated twice. What about this instead ?
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ee0274417948e0eb121792a400a0455884c92e56..23b776cd98796cf8eb4d19868a0506423226914d
100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3112,7 +3112,9 @@ static bool __splice_segment(struct page *page,
unsigned int poff,
poff += flen;
plen -= flen;
*len -= flen;
- } while (*len && plen);
+ if (!*len)
+ return true;
+ } while (plen);
return false;
}
Powered by blists - more mailing lists