linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c
@ 2005-04-11 21:55 Jesper Juhl
  2005-04-12  7:40 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-04-11 21:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Sailer, Greg Kroah-Hartman, linux-usb-devel

Checking for NULL before calling kfree() is redundant. This patch removes 
these redundant checks and also makes a few tiny whitespace changes.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---

 devio.c |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)

--- linux-2.6.12-rc2-mm3-orig/drivers/usb/core/devio.c	2005-04-11 21:20:49.000000000 +0200
+++ linux-2.6.12-rc2-mm3/drivers/usb/core/devio.c	2005-04-11 23:49:41.000000000 +0200
@@ -213,12 +213,10 @@ static struct async *alloc_async(unsigne
 
 static void free_async(struct async *as)
 {
-        if (as->urb->transfer_buffer)
-                kfree(as->urb->transfer_buffer);
-        if (as->urb->setup_packet)
-                kfree(as->urb->setup_packet);
+	kfree(as->urb->transfer_buffer);
+	kfree(as->urb->setup_packet);
 	usb_free_urb(as->urb);
-        kfree(as);
+	kfree(as);
 }
 
 static inline void async_newpending(struct async *as)
@@ -938,17 +936,13 @@ static int proc_do_submiturb(struct dev_
 		return -EINVAL;
 	}
 	if (!(as = alloc_async(uurb->number_of_packets))) {
-		if (isopkt)
-			kfree(isopkt);
-		if (dr)
-			kfree(dr);
+		kfree(isopkt);
+		kfree(dr);
 		return -ENOMEM;
 	}
 	if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) {
-		if (isopkt)
-			kfree(isopkt);
-		if (dr)
-			kfree(dr);
+		kfree(isopkt);
+		kfree(dr);
 		free_async(as);
 		return -ENOMEM;
 	}
@@ -967,8 +961,7 @@ static int proc_do_submiturb(struct dev_
 		as->urb->iso_frame_desc[u].length = isopkt[u].length;
 		totlen += isopkt[u].length;
 	}
-	if (isopkt)
-		kfree(isopkt);
+	kfree(isopkt);
 	as->ps = ps;
         as->userurb = arg;
 	if (uurb->endpoint & USB_DIR_IN)
@@ -1237,7 +1230,7 @@ static int proc_ioctl (struct dev_state 
 			return -ENOMEM;
 		if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) {
 			if (copy_from_user (buf, ctrl.data, size)) {
-				kfree (buf);
+				kfree(buf);
 				return -EFAULT;
 			}
 		} else {
@@ -1246,8 +1239,7 @@ static int proc_ioctl (struct dev_state 
 	}
 
 	if (!connected(ps->dev)) {
-		if (buf)
-			kfree(buf);
+		kfree(buf);
 		return -ENODEV;
 	}
 
@@ -1309,8 +1301,8 @@ static int proc_ioctl (struct dev_state 
 			&& size > 0
 			&& copy_to_user (ctrl.data, buf, size) != 0)
 		retval = -EFAULT;
-	if (buf != NULL)
-		kfree (buf);
+
+	kfree(buf);
 	return retval;
 }
 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c
  2005-04-11 21:55 [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c Jesper Juhl
@ 2005-04-12  7:40 ` Greg KH
  2005-04-12  8:40   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2005-04-12  7:40 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, Thomas Sailer, Greg Kroah-Hartman, linux-usb-devel

On Mon, Apr 11, 2005 at 11:55:22PM +0200, Jesper Juhl wrote:
> Checking for NULL before calling kfree() is redundant. This patch removes 
> these redundant checks and also makes a few tiny whitespace changes.
> 
> Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

Applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c
  2005-04-12  7:40 ` Greg KH
@ 2005-04-12  8:40   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2005-04-12  8:40 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Thomas Sailer, linux-usb-devel

On Tue, 12 Apr 2005, Greg KH wrote:

> Date: Tue, 12 Apr 2005 00:40:56 -0700
> From: Greg KH <gregkh@suse.de>
> To: Jesper Juhl <juhl-lkml@dif.dk>
> Cc: linux-kernel@vger.kernel.org, Thomas Sailer <sailer@ife.ee.ethz.ch>,
>     Greg Kroah-Hartman <gregkh@suse.de>, linux-usb-devel@lists.sourceforge.net
> Subject: Re: [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c
> 
> On Mon, Apr 11, 2005 at 11:55:22PM +0200, Jesper Juhl wrote:
> > Checking for NULL before calling kfree() is redundant. This patch removes 
> > these redundant checks and also makes a few tiny whitespace changes.
> > 
> > Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> 
> Applied, thanks.
> 
You're welcome. I have a patch 90% done that makes the same change for all 
of drivers/usb/* want me to send that along or would you prefer I stick to 
just drivers/usb/core/* ?  One huge patch OK or would you prefer it split 
into one patch pr modified file?   
I can send the patch later tonight when I get home from work.

-- 
Jesper Juhl


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-12  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-11 21:55 [PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c Jesper Juhl
2005-04-12  7:40 ` Greg KH
2005-04-12  8:40   ` Jesper Juhl

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).