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

From: SF Markus Elfring
Date: Wed Sep 20 2017 - 02:38:00 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

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);
--
2.14.1