Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47943234 authored by Julia Lawall's avatar Julia Lawall Committed by David S. Miller
Browse files

net/netlabel: Correct redundant test

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: 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 463889e2
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
	return 0;

cfg_unlbl_map_add_failure:
	if (entry != NULL)
	kfree(entry->domain);
	kfree(entry);
	kfree(addrmap);
@@ -385,7 +384,6 @@ 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);
	kfree(addrmap);