diff mbox

[2/3,media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions

Message ID a5db4b79-6b02-b49b-a618-fcb0f0ea762c@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Sept. 20, 2017, 6:37 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Sep 2017 22:12:49 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
index 0218614ce988..4349f9b5f838 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
@@ -98,10 +98,8 @@  void pvr2_ioread_destroy(struct pvr2_ioread *cp)
 	if (!cp) return;
 	pvr2_ioread_done(cp);
 	pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
-	if (cp->sync_key_ptr) {
-		kfree(cp->sync_key_ptr);
-		cp->sync_key_ptr = NULL;
-	}
+	kfree(cp->sync_key_ptr);
+	cp->sync_key_ptr = NULL;
 	kfree(cp);
 }
 
@@ -117,10 +115,8 @@  void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
 	     (!memcmp(sync_key_ptr,cp->sync_key_ptr,sync_key_len)))) return;
 
 	if (sync_key_len != cp->sync_key_len) {
-		if (cp->sync_key_ptr) {
-			kfree(cp->sync_key_ptr);
-			cp->sync_key_ptr = NULL;
-		}
+		kfree(cp->sync_key_ptr);
+		cp->sync_key_ptr = NULL;
 		cp->sync_key_len = 0;
 		if (sync_key_len) {
 			cp->sync_key_ptr = kmalloc(sync_key_len,GFP_KERNEL);