public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: Julia Lawall <julia@diku.dk>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	James Morris <jmorris@namei.org>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 5/5] security/selinux/ss: correct size computation
Date: Mon, 07 Dec 2009 10:02:23 -0500	[thread overview]
Message-ID: <1260198143.13226.9.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.0912061016310.20858@ask.diku.dk>

On Sun, 2009-12-06 at 10:16 +0100, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> 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/)
> 
> // <smpl>
> @expression@
> expression *x;
> @@
> 
> x =
>  <+...
> -sizeof(x)
> +sizeof(*x)
> ...+>// </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Acked-by: Eric Paris <eparis@redhat.com>

no real hurry, to get this in, the sizeof() is the same in either case,
but it should be fixed.


> 
> ---
>  security/selinux/ss/services.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -2555,7 +2555,7 @@ int security_get_classes(char ***classes
>  	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
>  	}
>  
>  	*nperms = match->permissions.nprim;
> -	*perms = kcalloc(*nperms, sizeof(*perms), GFP_ATOMIC);
> +	*perms = kcalloc(*nperms, sizeof(**perms), GFP_ATOMIC);
>  	if (!*perms)
>  		goto out;
>  



  reply	other threads:[~2009-12-07 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06  9:16 [PATCH 5/5] security/selinux/ss: correct size computation Julia Lawall
2009-12-07 15:02 ` Eric Paris [this message]
2009-12-07 22:11 ` James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1260198143.13226.9.camel@localhost \
    --to=eparis@redhat.com \
    --cc=jmorris@namei.org \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox