Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753110AbdLUR5S (ORCPT ); Thu, 21 Dec 2017 12:57:18 -0500 Received: from h2.hallyn.com ([78.46.35.8]:47704 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbdLUR5O (ORCPT ); Thu, 21 Dec 2017 12:57:14 -0500 Date: Thu, 21 Dec 2017 11:57:13 -0600 From: "Serge E. Hallyn" To: Vasyl Gomonovych Cc: casey@schaufler-ca.com, james.l.morris@oracle.com, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Smack: fix dereferenced before check Message-ID: <20171221175713.GB16008@mail.hallyn.com> References: <1513871872-18759-1-git-send-email-gomonovych@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1513871872-18759-1-git-send-email-gomonovych@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1169 Lines: 39 Quoting Vasyl Gomonovych (gomonovych@gmail.com): > 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 Looks obviously correct - thanks. Acked-by: Serge Hallyn > --- > security/smack/smack_lsm.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > 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, > #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)) > -- > 1.9.1