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>

authored by Julia Lawall and committed by Mike Frysinger 994e9a2e 5bc6e3cf

+8
+8
arch/blackfin/mach-common/smp.c
··· 211 211 return 0; 212 212 213 213 msg = kmalloc(sizeof(*msg), GFP_ATOMIC); 214 + if (!msg) 215 + return -ENOMEM; 214 216 INIT_LIST_HEAD(&msg->list); 215 217 msg->call_struct.func = func; 216 218 msg->call_struct.info = info; ··· 254 252 cpu_set(cpu, callmap); 255 253 256 254 msg = kmalloc(sizeof(*msg), GFP_ATOMIC); 255 + if (!msg) 256 + return -ENOMEM; 257 257 INIT_LIST_HEAD(&msg->list); 258 258 msg->call_struct.func = func; 259 259 msg->call_struct.info = info; ··· 291 287 return; 292 288 293 289 msg = kmalloc(sizeof(*msg), GFP_ATOMIC); 290 + if (!msg) 291 + return; 294 292 memset(msg, 0, sizeof(msg)); 295 293 INIT_LIST_HEAD(&msg->list); 296 294 msg->type = BFIN_IPI_RESCHEDULE; ··· 320 314 return; 321 315 322 316 msg = kmalloc(sizeof(*msg), GFP_ATOMIC); 317 + if (!msg) 318 + return; 323 319 memset(msg, 0, sizeof(msg)); 324 320 INIT_LIST_HEAD(&msg->list); 325 321 msg->type = BFIN_IPI_CPU_STOP;