mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pengtao He <hept.hept.hept@gmail.com>
To: edumazet@google.com
Cc: aleksander.lobakin@intel.com, almasrymina@google.com,
	davem@davemloft.net, ebiggers@google.com,
	hept.hept.hept@gmail.com, horms@kernel.org,
	kerneljasonxing@gmail.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, mhal@rbox.co,
	netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com
Subject: Re: [PATCH net-next v2] net/core: fix wrong return value in __splice_segment
Date: Thu, 24 Jul 2025 20:02:11 +0800	[thread overview]
Message-ID: <20250724120211.30050-1-hept.hept.hept@gmail.com> (raw)
In-Reply-To: <CANn89i+vzHO3yferPBi1kBmVkRAd1mu9gD0S8tUPdVaDXapkVw@mail.gmail.com>

> >
> > 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@gmail.com>
> > ---
> > v2->v1:
> > Correct the commit message and target tree.
> > v1:
> > https://lore.kernel.org/netdev/20250723063119.24059-1-hept.hept.hept@gmai=
> l.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, uns=
> igned int poff,
> >                 *len -=3D 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..23b776cd98796cf8eb4d19868a0=
> 506423226914d
> 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 +=3D flen;
>                 plen -=3D flen;
>                 *len -=3D flen;
> -       } while (*len && plen);
> +               if (!*len)
> +                       return true;
> +       } while (plen);
> 
>         return false;
>  }
> 
Ok, this is better.

Thanks.


      reply	other threads:[~2025-07-24 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24 10:29 Pengtao He
2025-07-24 11:18 ` Eric Dumazet
2025-07-24 12:02   ` Pengtao He [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=20250724120211.30050-1-hept.hept.hept@gmail.com \
    --to=hept.hept.hept@gmail.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhal@rbox.co \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®