Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Smack: fix dereferenced before check

This patch fixes the warning reported by smatch:
security/smack/smack_lsm.c:2872 smack_socket_connect() warn:
variable dereferenced before check 'sock->sk' (see line 2869)

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>

authored by

Vasyl Gomonovych and committed by
Casey Schaufler
da49b5da d21bd689

+5 -1
+5 -1
security/smack/smack_lsm.c
··· 2866 2866 #endif 2867 2867 #ifdef SMACK_IPV6_SECMARK_LABELING 2868 2868 struct smack_known *rsp; 2869 - struct socket_smack *ssp = sock->sk->sk_security; 2869 + struct socket_smack *ssp; 2870 2870 #endif 2871 2871 2872 2872 if (sock->sk == NULL) 2873 2873 return 0; 2874 + 2875 + #ifdef SMACK_IPV6_SECMARK_LABELING 2876 + ssp = sock->sk->sk_security; 2877 + #endif 2874 2878 2875 2879 switch (sock->sk->sk_family) { 2876 2880 case PF_INET: