From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753290AbdC2Po3 (ORCPT ); Wed, 29 Mar 2017 11:44:29 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:36520 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752248AbdC2PnZ (ORCPT ); Wed, 29 Mar 2017 11:43:25 -0400 MIME-Version: 1.0 X-Originating-IP: [108.49.102.27] In-Reply-To: References: From: Paul Moore Date: Wed, 29 Mar 2017 11:43:23 -0400 Message-ID: Subject: Re: [PATCH 42/46] selinux: One function call less in roles_init() after error detection To: SF Markus Elfring Cc: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , "Serge E. Hallyn" , Stephen Smalley , William Roberts , LKML , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 15, 2017 at 10:42 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 15 Jan 2017 12:56:54 +0100 > > The kfree() function was called in up to two cases by the > roles_init() function during error handling even if the passed variable > contained a null pointer. > > * Adjust a jump target according to the Linux coding style convention. > > * Delete an initialisation for the variable "key" at the beginning > which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring > --- > security/selinux/ss/policydb.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) Dropped due to unnecessary code churn with no significant advantage. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index be445abf047b..7dd5c6f7786f 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -174,7 +174,7 @@ static struct policydb_compat_info *policydb_lookup_compat(int version) > */ > static int roles_init(struct policydb *p) > { > - char *key = NULL; > + char *key; > int rc; > struct role_datum *role; > > @@ -185,13 +185,13 @@ static int roles_init(struct policydb *p) > role->value = ++p->p_roles.nprim; > if (role->value != OBJECT_R_VAL) { > rc = -EINVAL; > - goto out; > + goto free_role; > } > > key = kstrdup(OBJECT_R, GFP_KERNEL); > if (!key) { > rc = -ENOMEM; > - goto out; > + goto free_role; > } > > rc = hashtab_insert(p->p_roles.table, key, role); > @@ -201,6 +201,7 @@ static int roles_init(struct policydb *p) > return 0; > out: > kfree(key); > +free_role: > kfree(role); > return rc; > } > -- > 2.11.0 > -- paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Moore Date: Wed, 29 Mar 2017 15:43:23 +0000 Subject: Re: [PATCH 42/46] selinux: One function call less in roles_init() after error detection Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-security-module@vger.kernel.org On Sun, Jan 15, 2017 at 10:42 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 15 Jan 2017 12:56:54 +0100 > > The kfree() function was called in up to two cases by the > roles_init() function during error handling even if the passed variable > contained a null pointer. > > * Adjust a jump target according to the Linux coding style convention. > > * Delete an initialisation for the variable "key" at the beginning > which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring > --- > security/selinux/ss/policydb.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) Dropped due to unnecessary code churn with no significant advantage. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index be445abf047b..7dd5c6f7786f 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -174,7 +174,7 @@ static struct policydb_compat_info *policydb_lookup_compat(int version) > */ > static int roles_init(struct policydb *p) > { > - char *key = NULL; > + char *key; > int rc; > struct role_datum *role; > > @@ -185,13 +185,13 @@ static int roles_init(struct policydb *p) > role->value = ++p->p_roles.nprim; > if (role->value != OBJECT_R_VAL) { > rc = -EINVAL; > - goto out; > + goto free_role; > } > > key = kstrdup(OBJECT_R, GFP_KERNEL); > if (!key) { > rc = -ENOMEM; > - goto out; > + goto free_role; > } > > rc = hashtab_insert(p->p_roles.table, key, role); > @@ -201,6 +201,7 @@ static int roles_init(struct policydb *p) > return 0; > out: > kfree(key); > +free_role: > kfree(role); > return rc; > } > -- > 2.11.0 > -- paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: paul@paul-moore.com (Paul Moore) Date: Wed, 29 Mar 2017 11:43:23 -0400 Subject: [PATCH 42/46] selinux: One function call less in roles_init() after error detection In-Reply-To: References: Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Sun, Jan 15, 2017 at 10:42 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 15 Jan 2017 12:56:54 +0100 > > The kfree() function was called in up to two cases by the > roles_init() function during error handling even if the passed variable > contained a null pointer. > > * Adjust a jump target according to the Linux coding style convention. > > * Delete an initialisation for the variable "key" at the beginning > which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring > --- > security/selinux/ss/policydb.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) Dropped due to unnecessary code churn with no significant advantage. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index be445abf047b..7dd5c6f7786f 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -174,7 +174,7 @@ static struct policydb_compat_info *policydb_lookup_compat(int version) > */ > static int roles_init(struct policydb *p) > { > - char *key = NULL; > + char *key; > int rc; > struct role_datum *role; > > @@ -185,13 +185,13 @@ static int roles_init(struct policydb *p) > role->value = ++p->p_roles.nprim; > if (role->value != OBJECT_R_VAL) { > rc = -EINVAL; > - goto out; > + goto free_role; > } > > key = kstrdup(OBJECT_R, GFP_KERNEL); > if (!key) { > rc = -ENOMEM; > - goto out; > + goto free_role; > } > > rc = hashtab_insert(p->p_roles.table, key, role); > @@ -201,6 +201,7 @@ static int roles_init(struct policydb *p) > return 0; > out: > kfree(key); > +free_role: > kfree(role); > return rc; > } > -- > 2.11.0 > -- paul moore www.paul-moore.com -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html