Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da49b5da authored by Vasyl Gomonovych's avatar Vasyl Gomonovych Committed by Casey Schaufler
Browse files

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: default avatarVasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
parent d21bd689
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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))