]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: Remove redundant if check in sk_peer_get_label
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 4 Feb 2026 22:07:35 +0000 (23:07 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 22 Apr 2026 17:57:52 +0000 (10:57 -0700)
Remove the redundant if check in sk_peer_get_label() and return
ERR_PTR(-ENOPROTOOPT) directly.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/lsm.c

index 553f4127d59f53c16c4dea9cd0b7c819d6a41060..6f15b968a32a7f293c5237197975bc4ffc4f0e2f 100644 (file)
@@ -1523,15 +1523,11 @@ static int apparmor_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
 static struct aa_label *sk_peer_get_label(struct sock *sk)
 {
        struct aa_sk_ctx *ctx = aa_sock(sk);
-       struct aa_label *label = ERR_PTR(-ENOPROTOOPT);
 
        if (rcu_access_pointer(ctx->peer))
                return aa_get_label_rcu(&ctx->peer);
 
-       if (sk->sk_family != PF_UNIX)
-               return ERR_PTR(-ENOPROTOOPT);
-
-       return label;
+       return ERR_PTR(-ENOPROTOOPT);
 }
 
 /**