Skip to contentSkip to conversation

staging: gasket: remove null ptr check before kfree

PATCH In review Sumit Kumar 2 participants 2 messages Aug 12, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: gasket: remove null ptr check before kfree

Remove null ptr check before kfree because kfree is null ptr safe. Issue found by checkpatch.

---
 drivers/staging/gasket/gasket_page_table.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/gasket/gasket_page_table.c +2 -4
index d4c5f8a..bd921dc 100644
@@ -1328,10 +1328,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
 				  num_pages * PAGE_SIZE, mem, handle);
 	}
 
-	if (gasket_dev->page_table[index]->coherent_pages) {
-		kfree(gasket_dev->page_table[index]->coherent_pages);
-		gasket_dev->page_table[index]->coherent_pages = NULL;
-	}
+	kfree(gasket_dev->page_table[index]->coherent_pages);
+	gasket_dev->page_table[index]->coherent_pages = NULL;
 	gasket_dev->page_table[index]->num_coherent_pages = 0;
 	return -ENOMEM;
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Sumit Kumar

Remove null ptr check before kfree because kfree is null ptr safe. Issue found by checkpatch.

Hmm. Victim of copy-paste I guess.
No worries. Next time just use:

$  git commit -s

To understand what -s flag does, refer man git commit.

Quoted 1 line

---

Now, this where you should have put versions just below the '---':

v2:
- corrected email address.

And yes, the subject should be:

"Subject: [PATCH v2] staging: gasket: remove null ptr check before kfree"

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format

Hope that helps!

Signature · 4 lines
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology