lkml.org 
[lkml]   [2017]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/3] [media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions
From
Date
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 --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
\
 
 \ /
  Last update: 2017-09-20 08:38    [W:0.040 / U:1.404 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site