]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: limit scope of a skb_zerocopy_iter_stream var
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 27 Jun 2024 12:59:45 +0000 (13:59 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 2 Jul 2024 10:06:50 +0000 (12:06 +0200)
skb_zerocopy_iter_stream() only uses @orig_uarg in the !link_skb path,
and we can move the local variable in the appropriate block.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/skbuff.c

index 52986e1ce13ecded07d99f3a7a9ca9cfb5a9f6d6..0ed4d00d258c3f2381bab6aa2c0bbe483ac28d21 100644 (file)
@@ -1871,7 +1871,6 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
                             struct msghdr *msg, int len,
                             struct ubuf_info *uarg)
 {
-       struct ubuf_info *orig_uarg = skb_zcopy(skb);
        int err, orig_len = skb->len;
 
        if (uarg->ops->link_skb) {
@@ -1879,6 +1878,8 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
                if (err)
                        return err;
        } else {
+               struct ubuf_info *orig_uarg = skb_zcopy(skb);
+
                /* An skb can only point to one uarg. This edge case happens
                 * when TCP appends to an skb, but zerocopy_realloc triggered
                 * a new alloc.