From patchwork Sun Jan 15 15:27: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: 9517537 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 2B5F3601DA for ; Sun, 15 Jan 2017 15:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CE332849F for ; Sun, 15 Jan 2017 15:27:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EE9F284A1; Sun, 15 Jan 2017 15:27: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 BCF2D2849F for ; Sun, 15 Jan 2017 15:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256AbdAOP1X (ORCPT ); Sun, 15 Jan 2017 10:27:23 -0500 Received: from mout.web.de ([212.227.15.14]:51274 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204AbdAOP1W (ORCPT ); Sun, 15 Jan 2017 10:27:22 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MLgTT-1cRxlO3Fit-000qc2; Sun, 15 Jan 2017 16:27:09 +0100 Subject: [PATCH 27/46] selinux: Move an assignment for the variable "rc" in sens_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: <6b93ee88-d4c0-b5e3-6f7e-fc74acfddd43@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:27: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:jgIC6EpTqZutK7hqhjLRIfrFUnSjSPy74o0kzUSYIRrGfXG/aIj 9qg9SdqgIlJm/P/eu9lvOOxqP/vxIZF2rf9ix5orUx3mQx3wwfzt/M0UVQc6Fk3xh5ikNI8 Kj7hfrykirGeY2Gy890pE+ft0EVsncNNWTRZ7OYw828XHfoSTKrI3AM9ViJxpThQwEvFL1s lf5yXZpKzCyQ9YUb2Wt2Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:/M0yWWtzf3Y=:kfnk3iW5+jHAdTLdchUT6e GQxFQmoJf7jL/vxX9Rop/4ZNeG+BEA3Mtx/QnSFhgnd+D4heJ2FW74kYdNjH4f9qMLs+8PeCt LGKGuER6RtPb8U676rh0AfvWhErPkiJ5loteFUBELUr5h3tmmyclW6woefoEGnugwCFG5zDiM mzlbg9uh+2hZ/dnzCRIHxX2b99kHXye8aVTcjPwQ87Q2nsVN0SzOPDLcMxNqTQ6tFX5smFEA2 r5hbxKzeQ6PkjpMO/tNZr/4NC7fAdefd5Ct3CgHzcv7wLvvelF5pMuLiZkzcoPopnJJXz79QK jWhympbTyZ0gKbwHRSelWWXYIRo6v2842M4veue6RVnSGNbgFWxsy/p9fVUcr7RQH/uTYBgzc XD/fU4/9y9fPJfA74/ShacGtoJA98UTG5r67/v7I2jkAWuHTDATO8b2h1jRNO1B9hTDtdBz3w 2K9oYjCjQP0PiEBT4q6xTVcJClXABzIN0dB7txCXoGTPZOmyFfYjNWNDBrboS6bFB/TsbPJ92 grVtvT+Tn/J7BmKQfZ0ExOaQ1ySCZ/kqR5htmJDvjYidAf/SxnYZUPH6mmxeVIgLhWK7vaG93 uz6pkoTBU7tu4uK8L2R98jbYbmG/xblfA65MKA3nyshVCIKatmGyXglG01+7wOyKkb7TppyCP LSllBEFnnLocjflxb00HcgTWUC+WfXNuaNBYD9N6Vj99Cjt4VxrueNT0BxgW9Ue3ZdxXt/DOa gYIoBAAnzdm4yFeo/MtVsY9ra86nDLhvntyjEJfQ6VjE2VWd1ea6erJCZACoac9gfkaWzShgo cJcIehw 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 22:02:14 +0100 A local variable was set to an error code in one case before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there. Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index edfcfd3bbc60..3e43556e67b8 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1608,10 +1608,11 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp) if (rc) goto bad; - rc = -ENOMEM; levdatum->level = kmalloc(sizeof(*levdatum->level), GFP_ATOMIC); - if (!levdatum->level) + if (!levdatum->level) { + rc = -ENOMEM; goto bad; + } rc = mls_read_level(levdatum->level, fp); if (rc)