linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Mike Isely <isely@pobox.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/3] [media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions
Date: Wed, 20 Sep 2017 08:37:47 +0200	[thread overview]
Message-ID: <a5db4b79-6b02-b49b-a618-fcb0f0ea762c@users.sourceforge.net> (raw)
In-Reply-To: <c8117427-6d4d-0a1c-96c7-56e25d838b3e@users.sourceforge.net>

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

  parent reply	other threads:[~2017-09-20  6:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20  6:33 [PATCH 0/3] [media] pvrusb2-ioread: Fine-tuning for eight function implementations SF Markus Elfring
2017-09-20  6:36 ` [PATCH 1/3] [media] pvrusb2-ioread: Use common error handling code in pvr2_ioread_get_buffer() SF Markus Elfring
2017-09-20  6:37 ` SF Markus Elfring [this message]
2017-09-20  6:38 ` [PATCH 3/3] [media] pvrusb2-ioread: Delete unnecessary braces in six functions SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5db4b79-6b02-b49b-a618-fcb0f0ea762c@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=isely@pobox.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).