From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751435AbdAOPm3 (ORCPT ); Sun, 15 Jan 2017 10:42:29 -0500 Received: from mout.web.de ([212.227.15.4]:58675 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPm1 (ORCPT ); Sun, 15 Jan 2017 10:42:27 -0500 Subject: [PATCH 42/46] selinux: One function call less in roles_init() after error detection To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sun, 15 Jan 2017 16:42:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:bCWmQKO9E+URE7U4zqrC/hDS26B26sIyPf9s3ZTC9ZxBknRbZFJ dg6mCp5Fr+iZTIOrt3/S4FHT2G3LrODpIas6HDSVzFKyUckmcfCE5zNQJq/qHuO8QUOruMz cIN1Kowx6ni4qh7hR99N4U5OQs0X4cxm04lVLPzmaGx3Y/D87RPkMaGazcfTG1W2NiH0nqg SclWz6KQhuGBqlePDpoVg== X-UI-Out-Filterresults: notjunk:1;V01:K0:rpmgTvyPJQw=:W4wK3QE6n2C8PVkXyiHNy8 Rg3AtXUGZKLyTJRe5y7T1+hfoDwOv0pJdexxFhBlJlSiQVzvayY8ugOWBOgVe43VLYq4g9UGn fjv2hP+FhwiiIw99iC9kyE6OiV+9F3sQCK7MAZCaa782E9XSWlLNzYCkLXJs3iDtU4urNFhoL EC0oPQegSq7jAlklBu2eHFQ/TnzI6k7g7PlmPMJhmeZmvanySePhO0RshFlbcAaZDLnhLQpMq D6cVE8ldKsE9T4N/j143RqDdkB69lhMbkZsX7znNuHs7+2Ma5pRHlO5F0WWuk97rt0fb7M1F/ 3f7804sKlP5hWb9a9dCiXY+5WN155YJLsVielhv0Bnt+ZohYASTdCnklj/3KnJAqCVkEvJitG RB8H9nzd8COLBBXiJk1FOf2OsmheA7dWAEa7OdG95kYnbhA7U2K/Ki2z1VbvB5Rnoxus5aOve dgAcMUGAo0Cfw61YojeawvbJ2X4Xeo2qGT8rkTEvmTmp2auAGKSe5V5PfxMsMV4/q6qIqE6fE aIslxBRmEl3hqV/WOoF4/jZzm2xHIbXgSXJ2I6fkHxyhi1obOrntJyo5rBZ7CJcOQUq6Pl9bh 0+aHHtd7sYXVx8AmhDY3WE3X1A9wKzsjIRXrO96LBf4jE75/BAMRV8wkmkJByTxWIlPdlYntd nUqSGZJwM3y1kfx5Rw3jaNSBGRBVj8i4vVldt9s04Kkcpafj7iyt3WKKlYsKU0pKgVbFeSH6x urKokEZKuv2ddWewC8d5mHiGDMOEzTx5SOXU+CEYYY3iKqlp4va97YGHa/6sJu/Ztxy8kxBwM hw7sWnF Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sun, 15 Jan 2017 15:42:13 +0000 Subject: [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, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org 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(-) 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