From: Julia Lawall Date: Sun, 6 Dec 2009 09:16:51 +0000 (+0100) Subject: security/selinux/ss: correct size computation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9f59f90bf57cff8be07faddc608c400b6e7c5d05;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git security/selinux/ss: correct size computation The size argument to kcalloc should be the size of desired structure, not the pointer to it. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = <+... -sizeof(x) +sizeof(*x) ...+>// Signed-off-by: Julia Lawall Acked-by: Eric Paris Signed-off-by: James Morris --- diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index d6bb20cbad62..07ddc81d7b57 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -2555,7 +2555,7 @@ int security_get_classes(char ***classes, int *nclasses) read_lock(&policy_rwlock); *nclasses = policydb.p_classes.nprim; - *classes = kcalloc(*nclasses, sizeof(*classes), GFP_ATOMIC); + *classes = kcalloc(*nclasses, sizeof(**classes), GFP_ATOMIC); if (!*classes) goto out; @@ -2602,7 +2602,7 @@ int security_get_permissions(char *class, char ***perms, int *nperms) } *nperms = match->permissions.nprim; - *perms = kcalloc(*nperms, sizeof(*perms), GFP_ATOMIC); + *perms = kcalloc(*nperms, sizeof(**perms), GFP_ATOMIC); if (!*perms) goto out;