lkml.org 
[lkml]   [2009]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] sound/aoa: Add kmalloc NULL tests
At Fri, 31 Jul 2009 08:32:03 +0200 (CEST),
Julia Lawall wrote:
>
> From: Julia Lawall <julia@diku.dk>
>
> Check that the result of kzalloc is not NULL before a dereference.
>
> The semantic match that finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
>
> // <smpl>
> @@
> expression *x;
> identifier f;
> constant char *C;
> @@
>
> x = \(kmalloc\|kcalloc\|kzalloc\)(...);
> ... when != x == NULL
> when != x != NULL
> when != (x || ...)
> (
> kfree(x)
> |
> f(...,C,...,x,...)
> |
> *f(...,x,...)
> |
> *x->f
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied now.
But, please fix the path of the file correctly applicable to linux
kernel tree at the next time. It includes /var/x/y, and confuses git
am totally.

thanks,

Takashi

>
> ---
> sound/aoa/core/gpio-pmf.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/var/linuxes/linux-next/sound/aoa/core/gpio-pmf.c b/var/julia/linuxcopy/sound/aoa/core/gpio-pmf.c
> index 5ca2220..1dd0c28 100644
> --- a/var/linuxes/linux-next/sound/aoa/core/gpio-pmf.c
> +++ b/var/julia/linuxcopy/sound/aoa/core/gpio-pmf.c
> @@ -182,6 +182,10 @@ static int pmf_set_notify(struct gpio_runtime *rt,
> if (!old && notify) {
> irq_client = kzalloc(sizeof(struct pmf_irq_client),
> GFP_KERNEL);
> + if (!irq_client) {
> + err = -ENOMEM;
> + goto out_unlock;
> + }
> irq_client->data = notif;
> irq_client->handler = pmf_handle_notify_irq;
> irq_client->owner = THIS_MODULE;
>


\
 
 \ /
  Last update: 2009-07-31 10:19    [W:0.052 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site