From patchwork Sun Jan 15 15:16:02 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: 9517495 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 169A4607D4 for ; Sun, 15 Jan 2017 15:16:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B10C28488 for ; Sun, 15 Jan 2017 15:16:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F299E28496; Sun, 15 Jan 2017 15:16: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 B079528488 for ; Sun, 15 Jan 2017 15:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbdAOPQT (ORCPT ); Sun, 15 Jan 2017 10:16:19 -0500 Received: from mout.web.de ([212.227.15.3]:63853 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751045AbdAOPQS (ORCPT ); Sun, 15 Jan 2017 10:16:18 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LqDD6-1cxQSC1K9Q-00djxh; Sun, 15 Jan 2017 16:16:04 +0100 Subject: [PATCH 16/46] selinux: Move two assignments for the variable "rc" in filename_trans_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: Date: Sun, 15 Jan 2017 16:16:02 +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:fhYbu2DPAFtuMNvngQ1WSVT9qnvkC3BqT2bChZrf6MvpJgEHSwI 3X541ey6uB0/VoBAmABnqUdWJ5wwF6zx+WUsUrIjcI8sZbjMlmgKKEuhxPRRJeS0PKJ/0Qx yFWUHeRr3AqF/xeLJV/BeAaLnNNptjkVNWZABTHXdV1rXHgPdBz1Yb/9w40H50AGNa2dK6R R+D932CnkTiGqhm0pvhyw== X-UI-Out-Filterresults: notjunk:1; V01:K0:LWEBo5fcMO8=:24EM7A/uV17BZNTl0skZni ALp+p86+YArmvmd9YlOTfjY/MLm65LPNB6Ursw+XB0Hx1AUlKDO7ZfZ3tLI0BaaZmYbMdz0MH ZODeKM5cAUHyJ8C+i45fGaf+JtX53gAurIzZ6VbnaH3uuGBukqaiFQjzPf/nSwAlCe1IB9XQD 15kMwh3z+hLXVY7QHADjP8Rbpyh9DXy0YPW6cM6zVCCqn68lXsJTKDvphZiaPbumHKhjKIeIY Zeh75rHtTxwQpeL59wMg+JKRrFSG2FxDEse97ZlBkR/RztrTFXJtLY8sqMled/bsaaQScOMfl SQR9IZKYQ/pfuEVs+YeZowriMbAdgYHn33o9fLqXDBF9Z4rWvKHuYQovOg4zwp6jzhpyHjSOk vuhpMwkF9dShhp6eyU9Hyzi7sGJTbgqoFeKRZzV4fvPOrL9nusSpjGF5AOAhFuIKYcV7YrReY dNvC9qggwT7PtotJbjGrBuoRe2/i38V3rsNPzE1qFby8+mHuUl09DlkNv4njJrPgIzaPH4vOR 6ys6rEpa9NvOj+oOoCE+5aNhwqKRwKFIDI6eXULSqRvWBXiZv3qUmO22GqAQX+j2hn+HjEo3q A3njlgcKax0vQFyTHihUnNcOqdBAyGP0WxJOW7BIFWge4FxG8hxMQGmEWNwkeyM7bnsL9oqX7 9VPjqzwENZ0GcfLhv/TC+zaKCXrfQQg0azJR+9aoygpWh8oolNdXasiTuvIDgrHSX9rBQMnoX x1wtqshiz55iD/CWIt+r8kxZqwW5SaLZush879XqqPvlonETNWoiuMIL5yOemPY4RutRZWJL5 YhZgjw7 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:50:52 +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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index e7b882251da8..106a1da1d68a 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1930,16 +1930,17 @@ static int filename_trans_read(struct policydb *p, void *fp) ft = NULL; otype = NULL; name = NULL; - - rc = -ENOMEM; ft = kzalloc(sizeof(*ft), GFP_KERNEL); - if (!ft) + if (!ft) { + rc = -ENOMEM; goto out; + } - rc = -ENOMEM; otype = kmalloc(sizeof(*otype), GFP_KERNEL); - if (!otype) + if (!otype) { + rc = -ENOMEM; goto out; + } /* length of the path component string */ rc = next_entry(buf, fp, sizeof(u32));