提交 f065fabc 编写于 作者: J Julia Lawall 提交者: 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: NJulia Lawall <julia@diku.dk>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册