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


Groups > linux.kernel > #1203876 > unrolled thread

[PATCH 1/3] Staging: wilc1000: Remove null check before kfree

Started byShraddha Barke <shraddha.6596@gmail.com>
First post2015-08-10 10:10 +0200
Last post2015-08-11 01:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] Staging: wilc1000: Remove null check before kfree Shraddha Barke <shraddha.6596@gmail.com> - 2015-08-10 10:10 +0200
    Re: [PATCH 1/3] Staging: wilc1000: Remove null check before kfree "Dilger, Andreas" <andreas.dilger@intel.com> - 2015-08-11 01:40 +0200

#1203876 — [PATCH 1/3] Staging: wilc1000: Remove null check before kfree

FromShraddha Barke <shraddha.6596@gmail.com>
Date2015-08-10 10:10 +0200
Subject[PATCH 1/3] Staging: wilc1000: Remove null check before kfree
Message-ID<pVQjE-9c-15@gated-at.bofh.it>
kfree on NULL pointer is a no-op.

This patch uses the following semantic patch to find such an instance
where NULL check is present before kfree.

// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);
@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>smpl>

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
 drivers/staging/wilc1000/linux_wlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 3e55a8a..3dcd6e5 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -2343,8 +2343,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 
 done:
 
-	if (buff != NULL)
-		kfree(buff);
+	kfree(buff);
 
 	return s32Error;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1204636

From"Dilger, Andreas" <andreas.dilger@intel.com>
Date2015-08-11 01:40 +0200
Message-ID<pW4PE-4p8-7@gated-at.bofh.it>
In reply to#1203876
On 2015/08/10, 2:00 AM, "Shraddha Barke" <shraddha.6596@gmail.com> wrote:

>kfree on NULL pointer is a no-op.

Hi, please don't CC the hpdd-discuss list, nor Oleg or I for patches
unrelated to Lustre.

Cheers, Andreas

>This patch uses the following semantic patch to find such an instance
>where NULL check is present before kfree.
>
>// <smpl>
>@@ expression E; @@
>- if (E != NULL) { kfree(E); }
>+ kfree(E);
>@@ expression E; @@
>- if (E != NULL) { kfree(E); E = NULL; }
>+ kfree(E);
>+ E = NULL;
>// </smpl>smpl>
>
>Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>---
> drivers/staging/wilc1000/linux_wlan.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/drivers/staging/wilc1000/linux_wlan.c
>b/drivers/staging/wilc1000/linux_wlan.c
>index 3e55a8a..3dcd6e5 100644
>--- a/drivers/staging/wilc1000/linux_wlan.c
>+++ b/drivers/staging/wilc1000/linux_wlan.c
>@@ -2343,8 +2343,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq
>*req, int cmd)
> 
> done:
> 
>-	if (buff != NULL)
>-		kfree(buff);
>+	kfree(buff);
> 
> 	return s32Error;
> }
>-- 
>2.1.0
>
>


Cheers, Andreas
-- 
Andreas Dilger

Lustre Software Architect
Intel High Performance Data Division


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web