Commit ca7daea6 authored by Julia Lawall's avatar Julia Lawall Committed by David S. Miller

net/netlabel: Add kmalloc NULL tests

The test on map4 should be a test on map6.

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>
Acked-by: default avatarPaul Moore <paul.moore@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1b97440
...@@ -151,7 +151,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain, ...@@ -151,7 +151,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
addr6 = addr; addr6 = addr;
mask6 = mask; mask6 = mask;
map6 = kzalloc(sizeof(*map6), GFP_ATOMIC); map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
if (map4 == NULL) if (map6 == NULL)
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
map6->type = NETLBL_NLTYPE_UNLABELED; map6->type = NETLBL_NLTYPE_UNLABELED;
ipv6_addr_copy(&map6->list.addr, addr6); ipv6_addr_copy(&map6->list.addr, addr6);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment