From patchwork Sun Jan 15 15:18: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: 9517501 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 A289D607D4 for ; Sun, 15 Jan 2017 15:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E7D200E7 for ; Sun, 15 Jan 2017 15:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BD4528383; Sun, 15 Jan 2017 15:18:22 +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 3C2C1200E7 for ; Sun, 15 Jan 2017 15:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751152AbdAOPSV (ORCPT ); Sun, 15 Jan 2017 10:18:21 -0500 Received: from mout.web.de ([212.227.15.4]:63680 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbdAOPSU (ORCPT ); Sun, 15 Jan 2017 10:18:20 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Mbhiv-1cC5CP1Fnp-00J3vC; Sun, 15 Jan 2017 16:18:08 +0100 Subject: [PATCH 18/46] selinux: One function call less in filename_trans_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: <358b5114-aeb3-d5fa-bcf9-239bd383d3b5@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:18: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:VAKVF1c242b3ARdtajlXhrriN7FmJTzvkwYkw7YH3+sesotalG9 WbL4VqIm709zYSh6M7qxTONcRWD4tSyNBfdUMtL1W7bFLsKI/u7E4OSU//lvP+CbgGc49N6 P2J/L1QXD8O9TKPowE0zoYDWBayZ566O2w88JxmH9txcUn/skXpPo12zitDjMVHkVcbOhmH QKNmwFxKROcNyYzQw/7uQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Nyp/YVY9aBA=:gJ2hklmyf0zirmgBWRJztI X/zxG3TNFSLnXNYen4EAKuTq8JVX0MESR9S7pn+GMY1mAJRSurZPDbvQbHfY8xd5ALPn34Ed4 4qRN5DhEF1TH44IdBrpocUAJeciTm4ZgIG/hwkwMXdSC9FXL5GenYM5HESuJsIFTYNW/M1FDZ pb56QNnqH3R0HJUcD+rgdGbweoE5IpKo1zfxxFpie9cLjQ7ckg9qZwmDyUIWrS/iHXYp2pDuX VIWUi/F8lucDyhFamfayTuix7LVTFt9ojhy+FfjYSSAsGzDchK/YCe9iBgHlO3jN9EyV/yczr bYhqkIRu/tg5bnIl2EWnQb9EqMJP039W6wRUGmQMy8MWsc314T0bX1vsJgjWDCyJiKh1drxtY 82AEIQ0xUX6aJW4pPKP0Puk0Jymx6yk83Fx1bEtYyrI3vGIihkcQPjdnjK3B0ThgCcIWLTgMx 8wBVq+W+vTHoy7W0ZOTp5YujCQxhn2lLj/DHVw6u1HgnQJLdfAw6x0Sa/RHlvek964c3KbDHN NyI4inmLj1W5LMomUAsZ34orm/dJwzKBFbezeGnYGMlaJNby6mwsdAC0hNVtQC7R+cNEMFB0n vjAtkBUbNMsfFN6TR0BngSwMj+xqljGCs5CmuDMZz5oswvZLTZD2xru4CrsBacRzFFoHfpm6Q PzSXhv2HKBiGW8uZL9drgSCUIoUe/ZHAxuW9CAGFErC2Md3L6ylcoE3MeG0DDoETzSJvLJXei oU85nvfPdM2ARrI80ztJ2YHQqxMeSdy0WIeQht+Pl0qch4kbDVtf6ZI9zJIumHKH1EHju6GNQ WHBrV1S 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 19:19:42 +0100 Adjust a jump target to avoid a function call at the end after a memory allocation failed for the local variable "ft". Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 2be5b18eb149..5f122e846332 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1932,7 +1932,7 @@ static int filename_trans_read(struct policydb *p, void *fp) ft = kzalloc(sizeof(*ft), GFP_KERNEL); if (!ft) { rc = -ENOMEM; - goto out; + goto free_name; } otype = kmalloc(sizeof(*otype), GFP_KERNEL); @@ -1986,6 +1986,7 @@ static int filename_trans_read(struct policydb *p, void *fp) return 0; out: kfree(ft); +free_name: kfree(name); kfree(otype);