Skip to content

Commit

Permalink
net/netlabel: Correct redundant test
Browse files Browse the repository at this point in the history
entry was tested for NULL near the beginning of the function, followed by a
return, and there is no intervening modification of its value.

A simplified version of the semantic match that finds this problem is as
follows: (http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
expression E;
position p1,p2;
@@

if (x == NULL || ...) { ... when forall
   return ...; }
... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
(
*x == NULL
|
*x != NULL
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julia Lawall authored and David S. Miller committed Jul 27, 2009
1 parent 463889e commit 4794323
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/netlabel/netlabel_kapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
return 0;

cfg_unlbl_map_add_failure:
if (entry != NULL)
kfree(entry->domain);
kfree(entry->domain);
kfree(entry);
kfree(addrmap);
kfree(map4);
Expand Down Expand Up @@ -385,8 +384,7 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,

cfg_cipsov4_map_add_failure:
cipso_v4_doi_putdef(doi_def);
if (entry != NULL)
kfree(entry->domain);
kfree(entry->domain);
kfree(entry);
kfree(addrmap);
kfree(addrinfo);
Expand Down

0 comments on commit 4794323

Please sign in to comment.