Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752231AbdHMOuu (ORCPT ); Sun, 13 Aug 2017 10:50:50 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit 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: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1479 Lines: 56 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; -- 2.14.0