Skip to contentSkip to conversation

misc: remove meanless null check before kfree

PATCH In review zhong jiang 1 participant 2 messages Aug 17, 2018 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: remove meanless null check before kfree

kfree has taken null pointer into account. so check the null pointer before kfree is meanless.

---
 drivers/misc/sgi-xp/xpc_partition.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/sgi-xp/xpc_partition.c +1 -2
index 0c3ef6f..3eba1c4 100644
@@ -98,8 +98,7 @@
 			len = L1_CACHE_ALIGN(len);
 
 		if (len > buf_len) {
-			if (buf_base != NULL)
-				kfree(buf_base);
+			kfree(buf_base);
 			buf_len = L1_CACHE_ALIGN(len);
 			buf = xpc_kmalloc_cacheline_aligned(buf_len, GFP_KERNEL,
 							    &buf_base);
Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 2 lines · zhong jiang

kfree has taken null pointer into account. so check the null pointer before kfree is meanless.

meanless/meaningless. will repost. please ignore the patch, thanks.

Quoted 19 lines
---
 drivers/misc/sgi-xp/xpc_partition.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/sgi-xp/xpc_partition.c +1 -2
index 0c3ef6f..3eba1c4 100644
@@ -98,8 +98,7 @@
 			len = L1_CACHE_ALIGN(len);
 
 		if (len > buf_len) {
-			if (buf_base != NULL)
-				kfree(buf_base);
+			kfree(buf_base);
 			buf_len = L1_CACHE_ALIGN(len);
 			buf = xpc_kmalloc_cacheline_aligned(buf_len, GFP_KERNEL,
 							    &buf_base);