]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
arch/blackfin: Add kmalloc NULL tests
authorJulia Lawall <julia@diku.dk>
Tue, 14 Jul 2009 03:15:19 +0000 (03:15 +0000)
committerMike Frysinger <vapier@gentoo.org>
Thu, 16 Jul 2009 05:52:54 +0000 (01:52 -0400)
commit994e9a2e01f47f7ce24dec7edc45d70401468370
tree897d3dbae7e2ec383e02ae6a8dfd9de2cb8ba2d8
parent5bc6e3cfe6db5f33c60f042a9ba203431f334756
arch/blackfin: Add kmalloc NULL tests

Check that the result of kmalloc is not NULL before passing it to other
functions.

In the first two cases, the new code returns -ENOMEM, which seems
compatible with what is done for similar functions for other architectures.

In the last two cases, the new code fails silently, ie just returns,
because the function has void return type.

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: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
arch/blackfin/mach-common/smp.c