Skip to content

Commit

Permalink
Smack: fix dereferenced before check
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Casey Schaufler <[email protected]>
  • Loading branch information
Carmichael561 authored and cschaufler committed Dec 27, 2017
1 parent d21bd68 commit da49b5d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2866,12 +2866,16 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
#endif
#ifdef SMACK_IPV6_SECMARK_LABELING
struct smack_known *rsp;
struct socket_smack *ssp = sock->sk->sk_security;
struct socket_smack *ssp;
#endif

if (sock->sk == NULL)
return 0;

#ifdef SMACK_IPV6_SECMARK_LABELING
ssp = sock->sk->sk_security;
#endif

switch (sock->sk->sk_family) {
case PF_INET:
if (addrlen < sizeof(struct sockaddr_in))
Expand Down

0 comments on commit da49b5d

Please sign in to comment.