From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbdAOPCr (ORCPT ); Sun, 15 Jan 2017 10:02:47 -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 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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sun, 15 Jan 2017 15:02:30 +0000 Subject: [PATCH 05/46] selinux: Adjust four checks for null pointers Message-Id: <44727e74-99ac-b0bd-2d7b-e5928d77ea75@users.sourceforge.net> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Date: Sat, 14 Jan 2017 12:36:59 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit The script "checkpatch.pl" pointed information out like the following. Comparison to NULL could be written !=E2=80=A6 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 h= ashtab *h, const void * u32 i; =20 p =3D kzalloc(sizeof(*p), GFP_KERNEL); - if (p =3D NULL) + if (!p) return p; =20 p->size =3D size; @@ -25,7 +25,7 @@ struct hashtab *hashtab_create(u32 (*hash_value)(struct h= ashtab *h, const void * p->hash_value =3D hash_value; p->keycmp =3D keycmp; p->htable =3D kmalloc_array(size, sizeof(*p->htable), GFP_KERNEL); - if (p->htable =3D NULL) { + if (!p->htable) { kfree(p); return NULL; } @@ -58,7 +58,7 @@ int hashtab_insert(struct hashtab *h, void *key, void *da= tum) return -EEXIST; =20 newnode =3D kzalloc(sizeof(*newnode), GFP_KERNEL); - if (newnode =3D NULL) + if (!newnode) return -ENOMEM; newnode->key =3D key; newnode->datum =3D datum; @@ -87,7 +87,7 @@ void *hashtab_search(struct hashtab *h, const void *key) while (cur && h->keycmp(h, key, cur->key) > 0) cur =3D cur->next; =20 - if (cur =3D NULL || (h->keycmp(h, key, cur->key) !=3D 0)) + if (!cur || (h->keycmp(h, key, cur->key) !=3D 0)) return NULL; =20 return cur->datum; --=20 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html