Skip to content

Commit

Permalink
selinux: Improve size determinations in four functions
Browse files Browse the repository at this point in the history
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

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 e34cfef commit fb13a31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions security/selinux/ss/conditional.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
u32 len;
int rc;

booldatum = kzalloc(sizeof(struct cond_bool_datum), GFP_KERNEL);
booldatum = kzalloc(sizeof(*booldatum), GFP_KERNEL);
if (!booldatum)
return -ENOMEM;

Expand Down Expand Up @@ -332,7 +332,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
goto err;
}

list = kzalloc(sizeof(struct cond_av_list), GFP_KERNEL);
list = kzalloc(sizeof(*list), GFP_KERNEL);
if (!list) {
rc = -ENOMEM;
goto err;
Expand Down Expand Up @@ -421,7 +421,7 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
goto err;

rc = -ENOMEM;
expr = kzalloc(sizeof(struct cond_expr), GFP_KERNEL);
expr = kzalloc(sizeof(*expr), GFP_KERNEL);
if (!expr)
goto err;

Expand Down Expand Up @@ -472,7 +472,7 @@ int cond_read_list(struct policydb *p, void *fp)

for (i = 0; i < len; i++) {
rc = -ENOMEM;
node = kzalloc(sizeof(struct cond_node), GFP_KERNEL);
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
goto err;

Expand Down

0 comments on commit fb13a31

Please sign in to comment.