From patchwork Sun Jan 15 15:23:08 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: 9517521 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 5BDE1607D4 for ; Sun, 15 Jan 2017 15:23:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F6472849A for ; Sun, 15 Jan 2017 15:23:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43B85284A0; Sun, 15 Jan 2017 15:23:26 +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 F2F852849A for ; Sun, 15 Jan 2017 15:23:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751187AbdAOPXY (ORCPT ); Sun, 15 Jan 2017 10:23:24 -0500 Received: from mout.web.de ([212.227.15.3]:61255 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbdAOPXX (ORCPT ); Sun, 15 Jan 2017 10:23:23 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MddbY-1c5kVm0qlg-00PNLb; Sun, 15 Jan 2017 16:23:10 +0100 Subject: [PATCH 23/46] selinux: Move an assignment for a pointer in range_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: <668d71a5-d55c-449e-9de8-b5d70d7e11c9@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:23:08 +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:AFtxfqgrRNos1tWSlt1Q7KVV4VS12KibCI/at+PSr4kIavnwjrX rEGve5pShk8mnpYwDphkuPa6QNzpTSkjFBakdDrHwZ2SicQl/tP/YAxx1W2j2dHCi6Y2pAi 1CrsKA/WBXpODyoZHJnxnFhPlzGhDCBWViLuFDwcV8yDourjD/fRuQYiztt0/8BIv7K6sVw ebLkevvIPnGUQyRxdKgsQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:c7OtJXj0qYI=:st7YclQsRq70QGnexILHYP 7ihVCaa08fozGX5K3jWdoAJGdhqgpi9OPhrszXJeb64yYO3xPzVLE9yxzLgJgF+sqB4B1QV34 YkVcDw8LgyKS4A/SpkEQxlu0tkoLoBpQNEVYeKuS/iOMzTjvBGteMAnVvGhoQq9sMezlRVnod sdVmckep87MawriLBEXgrj6DJazkXQky9RDdkggKO29TrHg2MmwagGLA7rMekgOtsGA4pcSyJ diC7J2NC+FygcdzRY3Cj/fpmnpVp2Yn829l2PXa5UFYpCUKQoycWOK3uARAdzWcYdtEDoIXkK E93hj7rsh8CeYyV7XKMC1Qa+5mmxr1N5nORnwBbv0yF+KR5vhh+wFhP5LrwAPpQKx4N7HTV41 DJyNkkyf/B9HF69u21JI6+LkFsoyShJrEqoxxoWoBCHiz7bcFd44OGdj5o9z1sGLulicka30k AhNemBIWs1W+tqS/tBdELG+uIOOFTcI6RbJ6c8nUjQhXIgOWb2QFB5d5BJUaN09+BIrQQagnQ UXuQA/iQMCgdqrFYbywWgkQZWIs3jRsO1wZGWnylwY4zLjSmG/Q/Xw2oaKgL5H8koCObSBgM4 jT8Ieal1JzEz0Kb/tFNUPppGnsVIJBUuszg2Rb85v/27NsKDHE3f7gVYDrkRpx944kUhT9UF4 hl2pKZOdSj6tofgHAYjr0pT1oOlscwBCTxy0uOLvKqE1qCsS1wGkdTWeFyr/43L1p2rmvUeuF dWixC1gOzoanktaENTtpbMHqWaMKicMxXqgi4b8eCyeHq04GgjIqV0O02l+OWHW8oVY99H/sr 2efUCkT 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 21:00:45 +0100 Move the assignment for the local variable "r" behind a call of the function "next_entry" at the beginning so that it will only be set after a successful call. 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 6121a26ada64..5101592ae172 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1840,7 +1840,7 @@ u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) static int range_read(struct policydb *p, void *fp) { struct range_trans *rt; - struct mls_range *r = NULL; + struct mls_range *r; int i, rc; __le32 buf[2]; u32 nel; @@ -1852,6 +1852,7 @@ static int range_read(struct policydb *p, void *fp) if (rc) return rc; + r = NULL; nel = le32_to_cpu(buf[0]); for (i = 0; i < nel; i++) { rt = kzalloc(sizeof(*rt), GFP_KERNEL);