Skip to content

Commit

Permalink
USB: fix memleak in usbfs
Browse files Browse the repository at this point in the history
This patch fixes a memory leak in devio.c::processcompl

If writing to user space fails the packet must be discarded, as it
already has been removed from the queue of completed packets.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Jul 12, 2009
1 parent ba516de commit d794a02
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,22 +1231,22 @@ static int processcompl(struct async *as, void __user * __user *arg)
if (as->userbuffer)
if (copy_to_user(as->userbuffer, urb->transfer_buffer,
urb->transfer_buffer_length))
return -EFAULT;
goto err_out;
if (put_user(as->status, &userurb->status))
return -EFAULT;
goto err_out;
if (put_user(urb->actual_length, &userurb->actual_length))
return -EFAULT;
goto err_out;
if (put_user(urb->error_count, &userurb->error_count))
return -EFAULT;
goto err_out;

if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
for (i = 0; i < urb->number_of_packets; i++) {
if (put_user(urb->iso_frame_desc[i].actual_length,
&userurb->iso_frame_desc[i].actual_length))
return -EFAULT;
goto err_out;
if (put_user(urb->iso_frame_desc[i].status,
&userurb->iso_frame_desc[i].status))
return -EFAULT;
goto err_out;
}
}

Expand All @@ -1255,6 +1255,10 @@ static int processcompl(struct async *as, void __user * __user *arg)
if (put_user(addr, (void __user * __user *)arg))
return -EFAULT;
return 0;

err_out:
free_async(as);
return -EFAULT;
}

static struct async *reap_as(struct dev_state *ps)
Expand Down

0 comments on commit d794a02

Please sign in to comment.