]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
phonet/pep: Move call to pn_skb_get_dst_sockaddr() earlier in pep_sock_accept()
authorNathan Chancellor <nathan@kernel.org>
Tue, 15 Jul 2025 23:15:40 +0000 (16:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:22:27 +0000 (16:22 +0200)
commit 17ba793f381eb813596d6de1cc6820bcbda5ed8b upstream.

A new warning in clang [1] points out a place in pep_sock_accept() where
dst is uninitialized then passed as a const pointer to pep_find_pipe():

  net/phonet/pep.c:829:37: error: variable 'dst' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
    829 |         newsk = pep_find_pipe(&pn->hlist, &dst, pipe_handle);
        |                                            ^~~:

Move the call to pn_skb_get_dst_sockaddr(), which initializes dst, to
before the call to pep_find_pipe(), so that dst is consistently used
initialized throughout the function.

Cc: stable@vger.kernel.org
Fixes: f7ae8d59f661 ("Phonet: allocate sock from accept syscall rather than soft IRQ")
Link: https://github.com/llvm/llvm-project/commit/00dacf8c22f065cb52efb14cd091d441f19b319e
Closes: https://github.com/ClangBuiltLinux/linux/issues/2101
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20250715-net-phonet-fix-uninit-const-pointer-v1-1-8efd1bd188b3@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/phonet/pep.c

index 65d463ad87707782a44152014fa760798554145f..87066e3d48870128d7d03cc737ad289fb2a15a01 100644 (file)
@@ -825,6 +825,7 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp,
        }
 
        /* Check for duplicate pipe handle */
+       pn_skb_get_dst_sockaddr(skb, &dst);
        newsk = pep_find_pipe(&pn->hlist, &dst, pipe_handle);
        if (unlikely(newsk)) {
                __sock_put(newsk);
@@ -849,7 +850,6 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp,
        newsk->sk_destruct = pipe_destruct;
 
        newpn = pep_sk(newsk);
-       pn_skb_get_dst_sockaddr(skb, &dst);
        pn_skb_get_src_sockaddr(skb, &src);
        newpn->pn_sk.sobject = pn_sockaddr_get_object(&dst);
        newpn->pn_sk.dobject = pn_sockaddr_get_object(&src);