From patchwork Sun Jan 15 15:14:04 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: 9517487 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 87BEF607D4 for ; Sun, 15 Jan 2017 15:14:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C17428488 for ; Sun, 15 Jan 2017 15:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70F1B28496; Sun, 15 Jan 2017 15:14:34 +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 2F0EA28488 for ; Sun, 15 Jan 2017 15:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751263AbdAOPOU (ORCPT ); Sun, 15 Jan 2017 10:14:20 -0500 Received: from mout.web.de ([212.227.15.3]:62278 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751084AbdAOPOT (ORCPT ); Sun, 15 Jan 2017 10:14:19 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LiUF2-1d0koE2R0m-00cf1x; Sun, 15 Jan 2017 16:14:06 +0100 Subject: [PATCH 14/46] selinux: One function call less in genfs_read() after null pointer 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: <202d7312-b266-ce9d-8f7a-3e8282c7b0c5@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:14:04 +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:tSboql3ScgMAm3m+BcQKnfLs0YZnjCOh9CFazyN36vKfuRPkJvh q6zTnKgisWuyRU8utiCySTgxefY0bBtBVYN1BQOAEOxgH03eKYqXDp4m7WfpTOHLW01do5V iFo/2UUXS0kCLqNuRViPZJ8wWZHrPh//8/1Q22gGliHIrr6lLOvqtp91zYEIrM+TH41zTSI jVvnRHiN177yYnJPNiEWg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Lmy7GAxo56o=:npkddKEHITzp/l3yiF6w/A c9wyUdM01ySWMzerD7YqAO5IgAOJbF3UvT4/ljCQ2OGRkhQ4cuO6O/UviZYpMyhTEhP68bkwE NJAJ+/nlpfQ2v9dI1In/N63K1uzXvKfakYuXgSnqHQXRmyHIMobNPLXjeIxoz5QB0ifslMEI8 irqZuGPMeNxygT+hsjWUcpEXoUvJUDUs1LjtRhp2UXl65g7U/9CTmSAgW9nlOJCODpirOBa2f aCp+/GqRE4MrTjIVAjiMscnO5CDb4ik63CGPh9QkAbU5EAYvsN021AaMM9nZDdiPum5nKsmqo PwM1LAyg0z0raSSKgPNbsZ1w+w9/L4psNYti3kvceJC7Zl4a1S8yB8DNwZncBgPJ84JmQ2seP SOsjbnHvUpqM30VSR/cnYrxlw5jdqlq91vMnLuDakaUrPhy6V5/p3OhcHUixhGwgqVKWRDAxH cluMShuGJDV/pq244zmjPTORXjyqwkorKLTQUFqT5fnnjr9QTpNuN3TPmFeaSxiIBW8U44+YA fRjbVm4sRVKeCBdE+yL5ld+BdnmRX5+Czy0uZb814M70+8qx4HiO2dPdvXmXpOp9DsQ6/hxgX srovwFXVTSyz1ygJFjWlTJKtGafTdGAZ6zjDctme38rH8/jEvr6LrKt6A5vfE7C17dsudtS0M o2QkvrM2cVQDKO4CchnGbkpoAmnyfv//FHF0TUZj2k3xQpBXM+jjKxZkM/rjDsbIL60+3Bi3y 9r6rfyGy3E/3eMPvPVDwexMpAoKHFX6P8nmHSL+Ej/t479Inac9hH6vOQeS5TCby+RMYisua5 SDYISOE 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 17:43:47 +0100 Call the function "kfree" at the end only after it was determined that the local variable "newgenfs" contained a non-null pointer. 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 a12d9166f0e4..5dc31faa601f 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -2096,9 +2096,10 @@ static int genfs_read(struct policydb *p, void *fp) } rc = 0; out: - if (newgenfs) + if (newgenfs) { kfree(newgenfs->fstype); - kfree(newgenfs); + kfree(newgenfs); + } ocontext_destroy(newc, OCON_FSUSE); return rc;