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: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by Julia Lawall and committed by Takashi Iwai f065fabc 34fdeb2d

+4
+4
sound/aoa/core/gpio-pmf.c
··· 182 if (!old && notify) { 183 irq_client = kzalloc(sizeof(struct pmf_irq_client), 184 GFP_KERNEL); 185 irq_client->data = notif; 186 irq_client->handler = pmf_handle_notify_irq; 187 irq_client->owner = THIS_MODULE;
··· 182 if (!old && notify) { 183 irq_client = kzalloc(sizeof(struct pmf_irq_client), 184 GFP_KERNEL); 185 + if (!irq_client) { 186 + err = -ENOMEM; 187 + goto out_unlock; 188 + } 189 irq_client->data = notif; 190 irq_client->handler = pmf_handle_notify_irq; 191 irq_client->owner = THIS_MODULE;