Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;