From: Pengtao He Date: Tue, 19 Aug 2025 02:15:51 +0000 (+0800) Subject: net: avoid one loop iteration in __skb_splice_bits X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8f2c72f2252cf228879de0224d5055470fc20c06;p=users%2Fwilly%2Flinux.git net: avoid one loop iteration in __skb_splice_bits If *len is equal to 0 at the beginning of __splice_segment it returns true directly. But when decreasing *len from a positive number to 0 in __splice_segment, it returns false. The __skb_splice_bits needs to call __splice_segment again. Recheck *len if it changes, return true in time. Reduce unnecessary calls to __splice_segment. Signed-off-by: Pengtao He Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20250819021551.8361-1-hept.hept.hept@gmail.com Signed-off-by: Jakub Kicinski --- diff --git a/net/core/skbuff.c b/net/core/skbuff.c index ee0274417948..23b776cd9879 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; }