From patchwork Sun Jan 15 15:41:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9517595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 674EB62B9E for ; Sun, 15 Jan 2017 15:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A25E28387 for ; Sun, 15 Jan 2017 15:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F019283AC; Sun, 15 Jan 2017 15:41:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 034CB28387 for ; Sun, 15 Jan 2017 15:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751290AbdAOPlm (ORCPT ); Sun, 15 Jan 2017 10:41:42 -0500 Received: from mout.web.de ([212.227.15.4]:53340 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPlk (ORCPT ); Sun, 15 Jan 2017 10:41:40 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LaTdP-1cr9qp2MUZ-00mK0v; Sun, 15 Jan 2017 16:41:28 +0100 Subject: [PATCH 41/46] selinux: Move two assignments for the variable "rc" in roles_init() 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:41:25 +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: X-Provags-ID: V03:K0:sEHeklK9cjbifzNUkLxT9rBZ3Wc2nyAkdbbZoS+Oifm0i9DzcGu 5hlaaKQQjlsWQHBtwsIfX836/TECEMJU/Bd2JrWM9+Q/WlMlOnOrjqvVlcxD2RJeeAWux2t h9xhoY/rfPDCqgu//mPS+lGijMntsegKlHU9fOBUYDUt2j2DvzgZsHXzb+tk7gBEvVmDjSD kOrpaBC/HvBaL+sEqWxnQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:r8HE5r7aNaU=:n/UKnXHE67oQrNrXxxY2Cz +rwNhZTy9OqItfgTOgRV+NeSzS3iDF0CdTy/fHObtAAtbZydIEN7Nu6r58u5uGBlKKj0b9h2O HFxhTHVc1vSg64B3SjWLGi/j+Iqu8l0n8bofjnnhWiWv6G9EIbRv0+uBJY7Lc1E2c5LWGCgah Q0kw2A3xz9DgWFkmcUJBsvt+BZtbABo5oSXaRqq8GD4OBpNA0AfYjYvzoSPqW/jxhKKaIKBv7 k2lfWZOe+IyDHVzM8NqLA6yIWIN4jlIctAv7uMnsouj4y0VlCzCc1jwUurYN2OikKQS72StPU rDfvz2noe/1hwcZ+RK/CP+jlw/qjz9JZ+qOGlWkidxWG5qqZpwN2QCl3z1KohO14b9ULX+e5k N71Nvx37a5+8aTVbvBcu/X+qbqcnD7tYokYMiBWTd07xptO99FMmv5VKXliL6c7n4hGc9u+/P x4qYkKQ1bN/9R2qoBrgMQ0gHcPQi0Y1G++IBFYarlAL3zHfV/+gxk+1biZ5lt1/zikLz5wHA6 BEQ5rkpnOKBP8LUkfPVMJSRNq4CNWI9uDsd8n5fI3uX4RlSa4BJUL+FyUP1Ga2tM4B3EDgmrj ijHHWeClpqqMzKsy3Vq3Xfn+POJ7QNFm8essoLcwYtIhUjVqVWfGhfExDf6wE+2QPTa3RtnTR XZeWIy32j31R7syo34Yqky0uZj43vCUvt9LPpGPCkcALEGACRl1wUl66AEURNmBpPMPHgXWNb ksT91jXwmsUd0WYzkxhPQCzLDQ0x7l0ad10MIXQva2Vi8BoCCDaXQoONggBrFitkthtA+Gib7 vc85Km+ Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 15 Jan 2017 12:40:35 +0100 One local variable was set to an error code in two cases before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a software failure there. Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index ccc146bfd4c2..be445abf047b 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -182,15 +182,17 @@ static int roles_init(struct policydb *p) if (!role) return -ENOMEM; - rc = -EINVAL; role->value = ++p->p_roles.nprim; - if (role->value != OBJECT_R_VAL) + if (role->value != OBJECT_R_VAL) { + rc = -EINVAL; goto out; + } - rc = -ENOMEM; key = kstrdup(OBJECT_R, GFP_KERNEL); - if (!key) + if (!key) { + rc = -ENOMEM; goto out; + } rc = hashtab_insert(p->p_roles.table, key, role); if (rc)