From patchwork Sun Jan 15 15:31:10 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: 9517553 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 C2F4B601DA for ; Sun, 15 Jan 2017 15:31:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5ACB28387 for ; Sun, 15 Jan 2017 15:31:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9DF1283AC; Sun, 15 Jan 2017 15:31:27 +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 67F2D28387 for ; Sun, 15 Jan 2017 15:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbdAOPb0 (ORCPT ); Sun, 15 Jan 2017 10:31:26 -0500 Received: from mout.web.de ([212.227.15.3]:56730 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdAOPbZ (ORCPT ); Sun, 15 Jan 2017 10:31:25 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MFtOY-1cG9TC024s-00Esvq; Sun, 15 Jan 2017 16:31:12 +0100 Subject: [PATCH 31/46] selinux: Move an assignment for the variable "rc" in role_read() 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: <6df4c468-0b12-d053-6768-6f3245652427@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:31:10 +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:YweSeg//+fuE6ZCtAfTnvWRsxd/e3zdyCrsitRy638ThCgDC4DM DA/IcrbVJp7q+jK0KCW+PwAhU44pavxMZcr3ZCWWseCzIUZePqrBxdl/Hz6S+jsMFeCWtOr Qr6FOuSMqbJZX/UKcS7SrVb+Yqn8yOZ5A+j//eAOAzai4uwomjkuaglftgYS+rQYF7mLT5y O+s5sjR+KIOfzLOUMttYA== X-UI-Out-Filterresults: notjunk:1; V01:K0:pJzUgNvkUD4=:Gs93jo2gmGyuF3IDWTDOuM rQ1J9hJL53P83t+oamygp6J0pRrfDQpIESwEh4lS/IrwmZE96W+ct0ZSXRhjqKGbTLy72dhs8 UEG1BUBkahny7c0g5UKk/U77ylQaUWTzbgdxd96/ZfDIJMp9iS/XlRH97YnmIGWlAsYvArd2j vLurEoSWNl121bGiYg64NPcn4zEzVfDaQDy9xGDPkBKr52EPse4xJZv3UWjS97cr8rsYpy4Qk YqsWPHvwrl9gHRrZp29v8KBgupl2+1mAmyfNgOLxt1oLo/rA/A+hBhjF3UUar68MGaHoTjYgy Aeoqwwm9UFbqDRvOHwHIToQm+uVNMWe5e6Yg2rzlOBUst2ueFtVoH/bmKZ76gQVpBOsZgDh4x 1O0qoOzDBaqThj+cKEDbSzaFVaIpHsVPUn8Es2msWr+dhAzoeqTPbVslFd1nukOdD8OXhpgjk dGtOPl6ENc82YEmJ0RHFwkPlONl3xVdnnzQLVhisjkDMuvQ+Ezdy/VLbbgfzrVYlE1o+dbzht E/JKxfI5d8C96ybggTaOljsRHrYQADIZHAksSUGyx7oG4to+2NDpr9eKtohRjhDeYKf6Ksa9f M/c1oNUkEKlOBdjsFi6dSVJKhW00bqEDJg/bdaCUcxjXvwGvS/8Dd8/299Q5iXC3EHQEgMry1 XGtUAku9MA4RRm77f5wHsYaiQBu86LB9ZzdhwqjaAwarHQ/+8p1ImXP1TYKzI7c0lCBD+10zi Afahes/1J9SLFe8lBWlTKjmFjAaipFPzkydninxMSOC0mZu1Pl75+bfQ7QZ15q6m7cnFMU1GS lr/n/Iq Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 14 Jan 2017 22:25:20 +0100 A local variable was set to an error code in one case before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there. Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 34b670227c4d..49fc5d8990e9 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1439,10 +1439,10 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) goto bad; if (strcmp(key, OBJECT_R) == 0) { - rc = -EINVAL; if (role->value != OBJECT_R_VAL) { printk(KERN_ERR "SELinux: Role %s has wrong value %d\n", OBJECT_R, role->value); + rc = -EINVAL; goto bad; } rc = 0;