bpf: sockmap state change warning fix
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 16 Aug 2017 22:02:12 +0000 (15:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Aug 2017 22:34:13 +0000 (15:34 -0700)
psock will uninitialized in default case we need to do the same psock lookup
and check as in other branch. Fixes compile warning below.

kernel/bpf/sockmap.c: In function ‘smap_state_change’:
kernel/bpf/sockmap.c:156:21: warning: ‘psock’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  struct smap_psock *psock;

Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/sockmap.c

index 792f0addfafa2b3e4e88d865a93dbe4442455526..f7e5e6cf124aa31e6074f805318242756ca91fe9 100644 (file)
@@ -188,6 +188,9 @@ static void smap_state_change(struct sock *sk)
                        smap_release_sock(sk);
                break;
        default:
+               psock = smap_psock_sk(sk);
+               if (unlikely(!psock))
+                       break;
                smap_report_sk_error(psock, EPIPE);
                break;
        }