Skip to content

Commit

Permalink
selinux: Adjust four checks for null pointers
Browse files Browse the repository at this point in the history
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 <elfring@users.sourceforge.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
Markus Elfring authored and Paul Moore committed Mar 23, 2017
1 parent 2f00e68 commit cb8d21e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions security/selinux/ss/hashtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ 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;
p->nel = 0;
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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cb8d21e

Please sign in to comment.