From patchwork Sun Jan 15 15:02:30 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: 9517449 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 C176D60571 for ; Sun, 15 Jan 2017 15:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B492220246 for ; Sun, 15 Jan 2017 15:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6EF91FF8E; Sun, 15 Jan 2017 15:02:47 +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 31B971FF8E for ; Sun, 15 Jan 2017 15:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751107AbdAOPCp (ORCPT ); Sun, 15 Jan 2017 10:02:45 -0500 Received: from mout.web.de ([212.227.15.4]:65349 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751052AbdAOPCp (ORCPT ); Sun, 15 Jan 2017 10:02:45 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MIvaT-1cQIHh37bF-002VQA; Sun, 15 Jan 2017 16:02:32 +0100 Subject: [PATCH 05/46] selinux: Adjust four checks for null pointers 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: <44727e74-99ac-b0bd-2d7b-e5928d77ea75@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:02:30 +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:AyhajvzzxH+Mc1jQeCadpWcSiizgUKD9QjphycqZArJBvQPK74T 9RTjPq8/O4ZO8Dxk2tVc0/3bt7BEuxcu/yE12faiPrT9Eughydahj2bHEIqBcS+inY8+7AU VlpdamlCBzY6vF42gLenQYcBhzNo5g8/i1UWpsD6d+w5NqD19vMgYq7/x9GVzKrR/22LbeR 8UbDlGy96L6NhAFIgLZXQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:bYRxgFbxBI8=:e4sOoGD8FVIJlgrSZyBkMf vIaRRQHqvMXeyza5y0ocH4D/txy6pggWMpJTUnSky9qvqu+t5+BFfd+GX0ZXXk5luOL27KYvA EYm81iqrr9zNU7G0n7Zzk3cHO0lmep1zcNqxYUFzi8BAJxwbfTHuIaOPf0K/LowmR64GJYDyG 6vJbzWPijnmj7CBuTD9MAjgdJUcdBUQAUN9a1kjrZUSOvg+NuHS9WJDXDPBm+4lRi/MjHR87r ji2+GNeLHf06JL0yhKU/ojmUJruBDp+7Afr17e1Emqn8iFf3faT6mWZkBziUvrMtfPUNapv09 JpwO7g+B5f12QTjYN8ePS3G0wBino1lAvUDHIYpNBDelOPtzqN4G7FOgvqV/L3ByM7WsOSZMg hQac4kZuVz2lXnPzhOx/2iSWBLyBd0OLZ7dwXxyXHtVRkWgYkyTM+zMBC+h0dzFLmqTKcWUvg f4y+Dp7ua8bghxTWVG4KhUZOEuDv6sYh9HhlAeW53wasiMs0BeoRgeMxeFep2WfgGkyAMaqYn D/ZVcN2NOdnB0E5q9+hZAaSvZkBSc2mTEzAHgZXH5BeITZ32tkPfn5NYuyU24bi2IYgr2YC2Z AeRYJhfxHTFdAhhMmX/jZOR9B4bhJfLGGZoxkdAzEA8Hc2maP5MRQhUZ8j0ouAsQY7L6OMO15 /iAhyVb91+QTtvVvO23ZKw2Id/HdMCvYUCI1l61QJXLV3siN+aCLyLCTpmxNbHNfQyjOb3fVP +b1zjYR/BdRwROaxNhLZDC33yVv9twzKh4eL9OUDwLV4bik/KWN9c0GEyVTGeqLVt3aw62lPs 38J3TYn 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 12:36:59 +0100 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/hashtab.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/selinux/ss/hashtab.c b/security/selinux/ss/hashtab.c index dc99fff64ecb..3858706a29fb 100644 --- a/security/selinux/ss/hashtab.c +++ b/security/selinux/ss/hashtab.c @@ -17,7 +17,7 @@ struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void * u32 i; p = kzalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) + if (!p) return p; p->size = size; @@ -25,7 +25,7 @@ struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void * p->hash_value = hash_value; p->keycmp = keycmp; p->htable = kmalloc_array(size, sizeof(*p->htable), GFP_KERNEL); - if (p->htable == NULL) { + if (!p->htable) { kfree(p); return NULL; } @@ -58,7 +58,7 @@ int hashtab_insert(struct hashtab *h, void *key, void *datum) return -EEXIST; newnode = kzalloc(sizeof(*newnode), GFP_KERNEL); - if (newnode == NULL) + if (!newnode) return -ENOMEM; newnode->key = key; newnode->datum = datum; @@ -87,7 +87,7 @@ void *hashtab_search(struct hashtab *h, const void *key) while (cur && h->keycmp(h, key, cur->key) > 0) cur = cur->next; - if (cur == NULL || (h->keycmp(h, key, cur->key) != 0)) + if (!cur || (h->keycmp(h, key, cur->key) != 0)) return NULL; return cur->datum;