From patchwork Sun Jan 15 15:15:06 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: 9517489 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 45B07607D4 for ; Sun, 15 Jan 2017 15:15:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38FD628497 for ; Sun, 15 Jan 2017 15:15:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DC1E2849A; Sun, 15 Jan 2017 15:15:25 +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 C426B28488 for ; Sun, 15 Jan 2017 15:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751169AbdAOPPX (ORCPT ); Sun, 15 Jan 2017 10:15:23 -0500 Received: from mout.web.de ([212.227.15.4]:52814 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751084AbdAOPPW (ORCPT ); Sun, 15 Jan 2017 10:15:22 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M7VZv-1cgAs03EVr-00xKjJ; Sun, 15 Jan 2017 16:15:07 +0100 Subject: [PATCH 15/46] selinux: One check and function call less in genfs_read() 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:15:06 +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:3YPh5ulOTBWabKF6ifDWu8Ux8FQvb6xblT6VRhYd70BPJhTvYeB wRrG5Up9upkRUChv4kxCZGTeksXBoGLYVrWAjcvne40mbb3shh/YQFtVbuTbojcjhAQnCEE IijzNIBpwRR/pqkgjoSXVWY1jiIPwHSpuyYmY4w1UtTrkFWUI+GSPyxl0FwvX4g/6tdXFMW pByyRUzCozsS4a9RHLoLA== X-UI-Out-Filterresults: notjunk:1; V01:K0:o4tprKfawHE=:BlbgnZvNFj07qesJ+dVUxU cW3LImwY8M++alVaHHCIdC+kOjhJDC6W3b5wtN56XxrS3JUBOab214QQcaPo4TzOfMCFbD80B jfXUxDAilSoXoaa2M6VfCyO1rbnmVFyyC3VI9hG4l9OvJF+BOLKbmf/nSjBC/Q+ppXpiXvCt3 T6X4mMgvubEYpJNvwJuvQ7sYpCRSRvUtl5GoAhQX0I1tQ+6xsu0q/F6B5WZ9J+tDjKch8DBbL CSPsmMByPgmjgIT4i6chpEPZC/wUdJngtcet/o0RLWLOZhrFqDpgTXgi+UnLONBCQu0wQ9d/K jVRFFztfxnPUO88zvHLFIrZOjM7PD1l7Fdse0cA4xi72z7IhZBB2bY+BEmBnxvHMPNWzlmQQ3 FC0CxqjiQfdHAr1T1F3PGapyQT2U3ICTBbnK35aUU8wvht2PhlT9We0ddZ9nrpODBmKifwPSf jj9Lb9flmjuACnSdp3UoVQlNIMJAKNhgMmYWru+FUHKhjBHK9zjVhvd0e/PPsTNthqePBi9jt Xb9XSNYMhrv5fHhZGPxU3hqnTQal4dzQhsIaSPsNJAA2L4Vesflo+udYi+LbrWB5i9+j3xAeT B3PirrZ/5mJ+6NB6pRrcYtQJeuqxrxWtpQW3NmzF1fX1aDqHE5Up5pRhd2J0P7SL7FygG/pZo tOGqRsAf4/JF+Pn5PN25RekjfMX0uhAE9bRNUwkBi4gIlSvChdA1OuFOPlzzLudZFtChkStFF O/5ix3VEEocUc8MMOaQ+QLPfzkf4KyHlWpDyMcO7FiKP1Mw+QHh8ePrYoD0v4UBZ3UMi6Ram6 ipXrE/5 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 18:29:20 +0100 Adjust a jump target to avoid a check repetition at the end after a memory allocation failed for the local variable "newgenfs". Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 5dc31faa601f..e7b882251da8 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -2015,7 +2015,7 @@ static int genfs_read(struct policydb *p, void *fp) newgenfs = kzalloc(sizeof(*newgenfs), GFP_KERNEL); if (!newgenfs) { rc = -ENOMEM; - goto out; + goto exit; } rc = str_read(&newgenfs->fstype, GFP_KERNEL, fp, len); @@ -2101,7 +2101,7 @@ static int genfs_read(struct policydb *p, void *fp) kfree(newgenfs); } ocontext_destroy(newc, OCON_FSUSE); - +exit: return rc; }