ChangeSet 1.1276.22.30, 2003/08/22 16:18:53-07:00, abbotti@mev.co.uk [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). drivers/usb/serial/ftdi_sio.c | 25 ++++++++++--------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c --- a/drivers/usb/serial/ftdi_sio.c Tue Sep 2 12:46:17 2003 +++ b/drivers/usb/serial/ftdi_sio.c Tue Sep 2 12:46:17 2003 @@ -17,6 +17,11 @@ * See http://ftdi-usb-sio.sourceforge.net for upto date testing info * 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 * Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter. * VID/PID provided by Steve Briggs. @@ -1391,31 +1396,21 @@ 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 *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__)) return; + dbg("%s - port %d", __FUNCTION__, port->number); + if (urb->status) { dbg("nonzero write bulk status received: %d", urb->status); return; } - if (!serial) { - 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; + schedule_work(&port->work); } /* ftdi_write_bulk_callback */