Commit 0a270511 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

[PATCH] USB: ftdi_sio - fix memory leak and tidy up write bulk callback

The patch frees the bulk write urb's transfer buffer in the write
bulk callback (the buffer is allocated dynamically when the urb is
submitted).  The patch also tidies up the write bulk callback
function a little bit - removing some unnecessary paranoid checks
and scheduling a soft interrupt regardless of the port's open count
(for consistency with other usb serial drivers).
parent 6d28e037
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
* See http://ftdi-usb-sio.sourceforge.net for upto date testing info * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
* and extra documentation * and extra documentation
* *
* (19/Aug/2003) Ian Abbott
* Freed urb's transfer buffer in write bulk callback.
* Omitted some paranoid checks in write bulk callback that don't matter.
* Scheduled work in write bulk callback regardless of port's open count.
*
* (05/Aug/2003) Ian Abbott * (05/Aug/2003) Ian Abbott
* Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter. * Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter.
* VID/PID provided by Steve Briggs. * VID/PID provided by Steve Briggs.
...@@ -1391,31 +1396,21 @@ static int ftdi_write (struct usb_serial_port *port, int from_user, ...@@ -1391,31 +1396,21 @@ static int ftdi_write (struct usb_serial_port *port, int from_user,
static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs) static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
dbg("%s", __FUNCTION__); /* free up the transfer buffer, as usb_free_urb() does not do this */
kfree (urb->transfer_buffer);
if (port_paranoia_check (port, __FUNCTION__)) if (port_paranoia_check (port, __FUNCTION__))
return; return;
dbg("%s - port %d", __FUNCTION__, port->number);
if (urb->status) { if (urb->status) {
dbg("nonzero write bulk status received: %d", urb->status); dbg("nonzero write bulk status received: %d", urb->status);
return; return;
} }
if (!serial) { schedule_work(&port->work);
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
/* Have to check for validity of queueing up the tasks */
dbg("%s - port->open_count = %d", __FUNCTION__, port->open_count);
if (port->open_count > 0){
schedule_work(&port->work);
}
return;
} /* ftdi_write_bulk_callback */ } /* ftdi_write_bulk_callback */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment