[PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Jesper Juhl 2005-04-18 17:39:33 -07:00 committed by Greg K-H
parent acbb36f116
commit 6fd19f4b55
1 changed files with 12 additions and 20 deletions

View File

@ -213,9 +213,7 @@ static struct async *alloc_async(unsigned int numisoframes)
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);
usb_free_urb(as->urb);
kfree(as);
@ -938,16 +936,12 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
return -EINVAL;
}
if (!(as = alloc_async(uurb->number_of_packets))) {
if (isopkt)
kfree(isopkt);
if (dr)
kfree(dr);
return -ENOMEM;
}
if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) {
if (isopkt)
kfree(isopkt);
if (dr)
kfree(dr);
free_async(as);
return -ENOMEM;
@ -967,7 +961,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
as->urb->iso_frame_desc[u].length = isopkt[u].length;
totlen += isopkt[u].length;
}
if (isopkt)
kfree(isopkt);
as->ps = ps;
as->userurb = arg;
@ -1246,7 +1239,6 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
}
if (!connected(ps->dev)) {
if (buf)
kfree(buf);
return -ENODEV;
}
@ -1309,7 +1301,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
&& size > 0
&& copy_to_user (ctrl.data, buf, size) != 0)
retval = -EFAULT;
if (buf != NULL)
kfree(buf);
return retval;
}