aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasyl Gomonovych <gomonovych@gmail.com>2017-12-21 10:57:52 -0500
committerCasey Schaufler <casey@schaufler-ca.com>2017-12-27 17:43:19 -0500
commitda49b5dad18aad357ab8841ee65d415f683efc6f (patch)
tree244ed6c95034085c102d3c1a26c47573259ff962
parentd21bd6898336a7892914d308d5e0868f0b863571 (diff)
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>
-rw-r--r--security/smack/smack_lsm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 14cc7940b36d..30f2c3d1c11c 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2866,12 +2866,16 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
2866#endif 2866#endif
2867#ifdef SMACK_IPV6_SECMARK_LABELING 2867#ifdef SMACK_IPV6_SECMARK_LABELING
2868 struct smack_known *rsp; 2868 struct smack_known *rsp;
2869 struct socket_smack *ssp = sock->sk->sk_security; 2869 struct socket_smack *ssp;
2870#endif 2870#endif
2871 2871
2872 if (sock->sk == NULL) 2872 if (sock->sk == NULL)
2873 return 0; 2873 return 0;
2874 2874
2875#ifdef SMACK_IPV6_SECMARK_LABELING
2876 ssp = sock->sk->sk_security;
2877#endif
2878
2875 switch (sock->sk->sk_family) { 2879 switch (sock->sk->sk_family) {
2876 case PF_INET: 2880 case PF_INET:
2877 if (addrlen < sizeof(struct sockaddr_in)) 2881 if (addrlen < sizeof(struct sockaddr_in))