Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1460176

[PATCH v2 01/10] staging: ks7010: Delete unnecessary checks before the function call "kfree"

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH v2 01/10] staging: ks7010: Delete unnecessary checks before the function call "kfree"
Date 2016-08-11 07:30 +0200
Message-ID <s4QJ3-75c-11@gated-at.bofh.it> (permalink)
References (14 earlier) <mSsDN-4wa-63@gated-at.bofh.it> <mSsDN-4wa-65@gated-at.bofh.it> <mSsDN-4wa-33@gated-at.bofh.it> <rVYFQ-430-11@gated-at.bofh.it> <s4Qzn-70w-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Aug 2016 17:15:15 +0200

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/ks7010/ks7010_sdio.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index b7337fd..7da6c84 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -732,8 +732,7 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
 		goto error_out;
 	}
  error_out:
-	if (data_buf)
-		kfree(data_buf);
+	kfree(data_buf);
 	return rc;
 }
 
@@ -763,8 +762,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
 		goto error_out;
 	}
  error_out:
-	if (read_buf)
-		kfree(read_buf);
+	kfree(read_buf);
 	return rc;
 }
 
@@ -879,8 +877,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,
 	release_firmware(fw_entry);
  error_out0:
 	sdio_release_host(card->func);
-	if (rom_buf)
-		kfree(rom_buf);
+	kfree(rom_buf);
 	return rc;
 }
 
@@ -1199,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
 		unregister_netdev(netdev);
 
 		trx_device_exit(priv);
-		if (priv->ks_wlan_hw.read_buf) {
-			kfree(priv->ks_wlan_hw.read_buf);
-		}
+		kfree(priv->ks_wlan_hw.read_buf);
 		free_netdev(priv->net_dev);
 		card->priv = NULL;
 	}
-- 
2.9.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:20 +0200
  [PATCH v2 02/10] staging: ks7010: Delete unnecessary assignments for  buffer variables SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:30 +0200
  [PATCH v2 01/10] staging: ks7010: Delete unnecessary checks before  the function call "kfree" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:30 +0200
  [PATCH v2 04/10] staging: ks7010: Rename jump labels SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:40 +0200
  [PATCH v2 03/10] staging: ks7010: Return directly after a failed  kmalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:40 +0200
  [PATCH v2 05/10] staging: ks7010: Delete unnecessary uses of the  variable "retval" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:40 +0200
  [PATCH v2 06/10] staging: ks7010: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:50 +0200
  [PATCH v2 07/10] staging: ks7010: Add the macro "pr_fmt" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:50 +0200
  [PATCH v2 08/10] staging: ks7010: Replace three printk() calls by  pr_err() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 07:50 +0200
    Re: [PATCH v2 08/10] staging: ks7010: Replace three printk() calls  by pr_err() Joe Perches <joe@perches.com> - 2016-08-12 21:50 +0200
      Re: staging: ks7010: Replace three printk() calls by pr_err() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-13 13:20 +0200
        Re: staging: ks7010: Replace three printk() calls by pr_err() Joe Perches <joe@perches.com> - 2016-08-13 19:40 +0200
          Re: staging: ks7010: Replace three printk() calls by pr_err() Joe Perches <joe@perches.com> - 2016-08-14 11:00 +0200
            Re: staging: ks7010: Replace three printk() calls by pr_err() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-14 12:10 +0200
              Re: staging: ks7010: Replace three printk() calls by pr_err() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-14 13:10 +0200
          Re: staging: ks7010: Replace three printk() calls by pr_err() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-14 11:30 +0200
  [PATCH v2 09/10] staging: ks7010: Delete a variable in  write_to_device() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 08:00 +0200
  [PATCH v2 10/10] staging: ks7010: Delete three unnecessary variable  initialisations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-11 08:10 +0200
  Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card  driver SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-14 12:20 +0200
  Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card  driver Wolfram Sang <wsa@the-dreams.de> - 2016-08-14 14:10 +0200

csiph-web