diff mbox

[1/1] staging: gdm72xx: Remove redundant null check before kfree in gdm_wimax.c

Message ID 1353477576-26451-1-git-send-email-sachin.kamat@linaro.org
State Not Applicable
Headers show

Commit Message

Sachin Kamat Nov. 21, 2012, 5:59 a.m. UTC
kfree on a null pointer is a no-op.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/staging/gdm72xx/gdm_wimax.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Dan Carpenter Nov. 21, 2012, 9:17 a.m. UTC | #1
On Wed, Nov 21, 2012 at 11:29:36AM +0530, Sachin Kamat wrote:
> kfree on a null pointer is a no-op.
> 

kdelete() used to accept NULL pointers but now it will oops.  No one
ever passes a NULL pointer, so it doesn't cause a problem.  But if
you noticed that, please put it into the changelog so we don't freak
out.

regards,
dan carpenter
Sachin Kamat Nov. 21, 2012, 3:08 p.m. UTC | #2
On 21 November 2012 14:47, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Wed, Nov 21, 2012 at 11:29:36AM +0530, Sachin Kamat wrote:
>> kfree on a null pointer is a no-op.
>>
>
> kdelete() used to accept NULL pointers but now it will oops.

You are right. We can either leave it the way it was (i.e. drop this
patch) or I remove the NULL assignment
and re-send?

 No one
> ever passes a NULL pointer, so it doesn't cause a problem.  But if
> you noticed that, please put it into the changelog so we don't freak
> out.


>
> regards,
> dan carpenter
>
Greg KH Nov. 21, 2012, 9:51 p.m. UTC | #3
On Wed, Nov 21, 2012 at 08:38:29PM +0530, Sachin Kamat wrote:
> On 21 November 2012 14:47, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Wed, Nov 21, 2012 at 11:29:36AM +0530, Sachin Kamat wrote:
> >> kfree on a null pointer is a no-op.
> >>
> >
> > kdelete() used to accept NULL pointers but now it will oops.
> 
> You are right. We can either leave it the way it was (i.e. drop this
> patch) or I remove the NULL assignment
> and re-send?

Look at the code and determine what needs to be done.

thanks,

greg k-h
diff mbox

Patch

diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index c302769..ea5accd 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -535,10 +535,8 @@  static int gdm_wimax_close(struct net_device *dev)
 
 static void kdelete(void **buf)
 {
-	if (buf && *buf) {
-		kfree(*buf);
-		*buf = NULL;
-	}
+	kfree(*buf);
+	*buf = NULL;
 }
 
 static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)