Commit f065fabc authored by Julia Lawall's avatar Julia Lawall Committed by Takashi Iwai

ALSA: sound/aoa: Add kmalloc NULL tests

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: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 34fdeb2d
...@@ -182,6 +182,10 @@ static int pmf_set_notify(struct gpio_runtime *rt, ...@@ -182,6 +182,10 @@ static int pmf_set_notify(struct gpio_runtime *rt,
if (!old && notify) { if (!old && notify) {
irq_client = kzalloc(sizeof(struct pmf_irq_client), irq_client = kzalloc(sizeof(struct pmf_irq_client),
GFP_KERNEL); GFP_KERNEL);
if (!irq_client) {
err = -ENOMEM;
goto out_unlock;
}
irq_client->data = notif; irq_client->data = notif;
irq_client->handler = pmf_handle_notify_irq; irq_client->handler = pmf_handle_notify_irq;
irq_client->owner = THIS_MODULE; irq_client->owner = THIS_MODULE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment