]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: sock_release_ownership() cleanup
authorEric Dumazet <edumazet@google.com>
Mon, 11 Sep 2023 17:05:29 +0000 (17:05 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 12 Sep 2023 17:10:01 +0000 (19:10 +0200)
sock_release_ownership() should only be called by user
owning the socket lock.

After prior commit, we can remove one condition.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/sock.h

index b770261fbdaf59d4d1c0b30adb2592c56442e9e3..676146e9d18117e3a04fbbfb0a06e511a80d537c 100644 (file)
@@ -1823,12 +1823,11 @@ static inline bool sock_owned_by_user_nocheck(const struct sock *sk)
 
 static inline void sock_release_ownership(struct sock *sk)
 {
-       if (sock_owned_by_user_nocheck(sk)) {
-               sk->sk_lock.owned = 0;
+       DEBUG_NET_WARN_ON_ONCE(!sock_owned_by_user_nocheck(sk));
+       sk->sk_lock.owned = 0;
 
-               /* The sk_lock has mutex_unlock() semantics: */
-               mutex_release(&sk->sk_lock.dep_map, _RET_IP_);
-       }
+       /* The sk_lock has mutex_unlock() semantics: */
+       mutex_release(&sk->sk_lock.dep_map, _RET_IP_);
 }
 
 /* no reclassification while locks are held */