aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/ss
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-04-28 15:55:52 -0400
committerEric Paris <eparis@redhat.com>2011-04-28 16:12:47 -0400
commit5d30b10bd68df007e7ae21e77d1e0ce184b53040 (patch)
tree61d97a80d0fac7c6dfd97db7040fedd75771adda /security/selinux/ss
parentcb1e922fa104bb0bb3aa5fc6ca7f7e070f3b55e9 (diff)
flex_array: flex_array_prealloc takes a number of elements, not an end
Change flex_array_prealloc to take the number of elements for which space should be allocated instead of the last (inclusive) element. Users and documentation are updated accordingly. flex_arrays got introduced before they had users. When folks started using it, they ended up needing a different API than was coded up originally. This swaps over to the API that folks apparently need. Based-on-patch-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Eric Paris <eparis@redhat.com> Tested-by: Chris Richards <gizmo@giz-works.com> Acked-by: Dave Hansen <dave@linux.vnet.ibm.com> Cc: stable@kernel.org [2.6.38+]
Diffstat (limited to 'security/selinux/ss')
-rw-r--r--security/selinux/ss/policydb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index e7b850ad57ee..e6e7ce0d3d55 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -502,7 +502,7 @@ static int policydb_index(struct policydb *p)
502 goto out; 502 goto out;
503 503
504 rc = flex_array_prealloc(p->type_val_to_struct_array, 0, 504 rc = flex_array_prealloc(p->type_val_to_struct_array, 0,
505 p->p_types.nprim - 1, GFP_KERNEL | __GFP_ZERO); 505 p->p_types.nprim, GFP_KERNEL | __GFP_ZERO);
506 if (rc) 506 if (rc)
507 goto out; 507 goto out;
508 508
@@ -519,7 +519,7 @@ static int policydb_index(struct policydb *p)
519 goto out; 519 goto out;
520 520
521 rc = flex_array_prealloc(p->sym_val_to_name[i], 521 rc = flex_array_prealloc(p->sym_val_to_name[i],
522 0, p->symtab[i].nprim - 1, 522 0, p->symtab[i].nprim,
523 GFP_KERNEL | __GFP_ZERO); 523 GFP_KERNEL | __GFP_ZERO);
524 if (rc) 524 if (rc)
525 goto out; 525 goto out;
@@ -2375,7 +2375,7 @@ int policydb_read(struct policydb *p, void *fp)
2375 goto bad; 2375 goto bad;
2376 2376
2377 /* preallocate so we don't have to worry about the put ever failing */ 2377 /* preallocate so we don't have to worry about the put ever failing */
2378 rc = flex_array_prealloc(p->type_attr_map_array, 0, p->p_types.nprim - 1, 2378 rc = flex_array_prealloc(p->type_attr_map_array, 0, p->p_types.nprim,
2379 GFP_KERNEL | __GFP_ZERO); 2379 GFP_KERNEL | __GFP_ZERO);
2380 if (rc) 2380 if (rc)
2381 goto bad; 2381 goto bad;