]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net/sock: add WARN_ON(parent->sk) in sock_graft()
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 6 Jul 2017 15:15:07 +0000 (08:15 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 26 Jul 2017 03:56:47 +0000 (20:56 -0700)
sock_graft() unilaterally sets up parent->sk based on the
assumption that the existing parent->sk is null. If this
condition is not true, then the existing parent->sk would
be leaked, so add a WARN_ON() to alert callers who may fall
in this category.

Orabug: 26477756

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
include/net/sock.h

index 5374c0dff793d72c988d1c33ab6e60f1a776a2f1..71431f99fcfc4be159d11b7d28098714c97efa22 100644 (file)
@@ -1686,6 +1686,7 @@ static inline void sock_orphan(struct sock *sk)
 
 static inline void sock_graft(struct sock *sk, struct socket *parent)
 {
+       WARN_ON(parent->sk);
        write_lock_bh(&sk->sk_callback_lock);
        sk->sk_wq = parent->wq;
        parent->sk = sk;