From patchwork Sun Aug 13 14:50:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9897895 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 788BA60244 for ; Sun, 13 Aug 2017 14:50:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 597622861D for ; Sun, 13 Aug 2017 14:50:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CA3528620; Sun, 13 Aug 2017 14:50:50 +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 E57F52861D for ; Sun, 13 Aug 2017 14:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbdHMOus (ORCPT ); Sun, 13 Aug 2017 10:50:48 -0400 Received: from mout.web.de ([212.227.15.4]:59496 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbdHMOur (ORCPT ); Sun, 13 Aug 2017 10:50:47 -0400 Received: from [192.168.1.2] ([92.228.32.17]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MPY5x-1dcnUD24Cf-004mdD; Sun, 13 Aug 2017 16:50:12 +0200 Subject: [PATCH 4/4] selinux: Adjust five checks for null pointers From: SF Markus Elfring To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Alexey Dobriyan , Daniel Jurgens , Eric Paris , James Morris , Junil Lee , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Sun, 13 Aug 2017 16:50:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:b5ivtW/BVZoMGb37E/aR418i70xSuOceyr/nbyxCHCFo963ZnTP V9ObTPT+ApEw6Iq0rkoxS+OdHx2/bipa6HWCq/b+yFuZDVHdEg0yBpX4Y9ZSvibJNeP3TTO gFwzG3yzeQOj19QPb6aQqFTBtmKEvNJNv4l71l3u1I5dtUaZ856sQi5V9GUEAsVmWfLmoar YkqykrYXtL4Wk8gyuDKqQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:D/Nxu2bqd+k=:JisLuq1HXaUYBmCKJJQ3iJ qwP9SvGWFaXJzQxjbJ/NsbLvZp3Y6d5DFKyqNvydrmEIHLS6K4gm0zC/zEqd+yvNmS6c6798A 4Uw+RYVaBClYanX/YBOU1Z5tgWr3Yvr6fB+6l2yWl+SHIyJ18zU+5vdRktHfiCoISLWRWUK3r 8zY0V0kIB8UIFS8w3LbEhtn/j3QbOYOjqjIMUAlwOmDxTpkTUPKb5vEMIeTBPVJSc7l6+bw9e BagMWugEhRYg8Ty245MeMOE4rNpV83eFMPhfkczfT3mo682+csLmZhWGiuxHbPTwc9+M7Cye9 7jNG+IYVxXcVzXy7u0V7dUKseERanekgJeyX+9N962Jc+oowCkATk467z21oFr9zMOIsSSNGq Lk2dZqCHFEK0f+K7wjsMKuTlUbXjfn4z+49Dii0Blg3RFsAf+iXqZvKB7+cw6Mgd286Yiw/Ki mPu1ZC46e5yA+0AEDSNNtOGqlYzx5g+18PJfOTOLEFjpBzQaKaOlTCKmC0e9KE/Q9OMlazZ4/ 8+UBIfmgHARZp5I9PLOJo902zHyqhUfoqibzL2KAYofwJs2aeVuYzvMjfUlqg4kwdsglb4M4W FrJn+2d7ZkgIOqt2PfY0ipf68FgTKNQoGgi0SuniMqHFhr0rZV7KT+owW0ysVUZBc35G9xVHM 4oAihBEgOooWxfWwZY7SbQ1sGWDd7zinXRD8HZA3hHY1bKUtW+EobednklMOUQ9q+zqsEFj3h TsqigxzQwz9mBCGoOx799m9jmYtXuKCl6uh43aQxnyIyKQN7PzHP0adh45bWPqI6P98zkq6Y2 OVUNTqSeLvWEfXQ1iOFPtze7LiUtw36lLidr9vW07XFNOsZ9qE= Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 13 Aug 2017 16:16:05 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix affected source code places. Signed-off-by: Markus Elfring --- security/selinux/ss/ebitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c index 697bd748760a..c778135989f5 100644 --- a/security/selinux/ss/ebitmap.c +++ b/security/selinux/ss/ebitmap.c @@ -96,12 +96,12 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap, unsigned int iter; int rc; - if (e_iter == NULL) { + if (!e_iter) { *catmap = NULL; return 0; } - if (*catmap != NULL) + if (*catmap) netlbl_catmap_free(*catmap); *catmap = NULL; @@ -161,14 +161,14 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap, continue; } - if (e_iter == NULL || + if (!e_iter || offset >= e_iter->startbit + EBITMAP_SIZE) { e_prev = e_iter; e_iter = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC); - if (e_iter == NULL) + if (!e_iter) goto netlbl_import_failure; e_iter->startbit = offset - (offset % EBITMAP_SIZE); - if (e_prev == NULL) + if (!e_prev) ebmap->node = e_iter; else e_prev->next = e_iter;