Skip to contentSkip to conversation

netfilter: remove redundant null check before kvfree()

PATCH New Subasri S 1 participant 1 message Jun 25

Subsystems (3)
lore
Share & tools
lore

Subasri S

author
#0 lore raw

PATCH 1/1 netfilter: remove redundant null check before kvfree()

kvfree() internally performs NULL check on the pointer handed to it and takes no action if it indeed is NULL. Hence there is no need for a pre-check of the memory pointer before handing it to kvfree().

Issue reported by ifnullfree.cocci Coccinelle semantic patch script.

---
 net/netfilter/nft_set_rbtree.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/netfilter/nft_set_rbtree.c +1 -2
index 018bbb6df4ce..efc25e788a1c 100644
@@ -544,8 +544,7 @@ static int nft_array_intervals_alloc(struct nft_array *array, u32 max_intervals)
 	if (!intervals)
 		return -ENOMEM;
 
-	if (array->intervals)
-		kvfree(array->intervals);
+	kvfree(array->intervals);
 
 	array->intervals = intervals;
 	array->max_intervals = max_intervals;
Signature · 1 line
2.43.0