From patchwork Sun Jan 15 15:21:15 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: 9517513 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 DC7DA607D4 for ; Sun, 15 Jan 2017 15:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D088C28383 for ; Sun, 15 Jan 2017 15:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5444283E0; Sun, 15 Jan 2017 15:21:32 +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 74FB128383 for ; Sun, 15 Jan 2017 15:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750831AbdAOPVb (ORCPT ); Sun, 15 Jan 2017 10:21:31 -0500 Received: from mout.web.de ([212.227.15.14]:51563 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbdAOPVa (ORCPT ); Sun, 15 Jan 2017 10:21:30 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MHYHE-1cRhDd4B00-003KCi; Sun, 15 Jan 2017 16:21:18 +0100 Subject: [PATCH 21/46] selinux: Two function calls less in range_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: <1e37fe86-2e83-c1f0-f43b-69ed2fb5c7aa@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:21:15 +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:1PirTEJ6HoTESOgb9ym5dcA2aegrEjCt4TyM965/ux8Nu+6ykCz vfva+HidpDcvGKVblmr95S42QEKn95Yq+P5wrK1FM4QGfyBnKOpQymFOu8Ea8uWucCWo5d/ l9xsI1O9Tzuu/KsvamWTb8h0jmAOlvRMrE2otay8EKKl87jBqyk/+bn93Vq/Xw8SdKQNe/5 HtgBR0fGY79zywpLhJc3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:XSD5YwtEbUk=:tdIcc4cZxrSloZKuB6099b OCnYuneIsy/jlNzDBcHtJQPlk1gx3EZQeDS+zuQO5NQu1rmeFMM5cNQ5tYS0plviZLfN1GmbB eJHznkv2x9l2NdeqdI5z0371A+9jCOF+rep8Dmu/5VdyMjSj8OqVdCnWo5+4nThlK7BEwzOjA s14YPvi8WeLpRaB78sAnvap/gGQWsuP7oXjd/Dqoo0k3wpOWLGG09Iml5Mk5GgM0Nq10M52Zn y6wbQ7mscs5ZbwfQWqZ/Nrb+yskQCF8nLlTM/AEbNYBXdHjWBLHea3bHrDJqbAV5JoowNWLdK 5ad05P35Lwu0fMr+eyY9OKh/EMh3P+jEzPVjzu/LOSGbjQx6LZc1xszMtu4iLHsjYDCobQ6gZ gRUx+KUAFnlHn4gYjHfwJJdPulfk8QDwYZ61H+JMVW64pX58kn1q5kQs1uiz+jMW0RQmq1F+3 6qOC8Q3Yz+gAZuyAYQdDA/o/nnxxMmf2yndmdI1oDDEth8cDiUS7cAZavSxoF4+acXaEyfNCe oLKHw1KSDKGkyqMFIgyJY/W2IilitYBtIUd8V41Smg9B04K4oG1r/oY4ofzsC7osTJnYwx81N fy5yuXl+VIBNBz12fz9+eifXFdwFAPBRIu6ONXJqJceeowadAj/8NlMZnUqTgj2rHebbQxVE/ 3pEei+MZYysbJGsvm64BSSd7odnj5Lxknf0Hj4lTP8LtgqhajWYEVDIZLWvNjmlljmXXS8TtC YEfTbbDuCTSRHhGP2Hq/YBZRVWkgSNtV3DDpyHJFg4B2P0S8Ue0ELT/gsQ8aPnNtvcNKp7F8G gCrwn/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 20:20:15 +0100 Adjust a jump target to avoid two calls of the function "kfree" at the end after a memory allocation failed for the local variable "rt". 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 4cd96ce51322..0d2f64558c0a 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1857,7 +1857,7 @@ static int range_read(struct policydb *p, void *fp) rt = kzalloc(sizeof(*rt), GFP_KERNEL); if (!rt) { rc = -ENOMEM; - goto out; + goto exit; } rc = next_entry(buf, fp, (sizeof(u32) * 2)); @@ -1909,6 +1909,7 @@ static int range_read(struct policydb *p, void *fp) out: kfree(rt); kfree(r); +exit: return rc; }