Skip to content

Commit c92e73b

Browse files
romain-izard-progregkh
authored andcommitted
usb: cdc_acm: Do not leak URB buffers
commit f2924d4 upstream. When the ACM TTY port is disconnected, the URBs it uses must be killed, and then the buffers must be freed. Unfortunately a previous refactor removed the code freeing the buffers because it looked extremely similar to the code killing the URBs. As a result, there were many new leaks for each plug/unplug cycle of a CDC-ACM device, that were detected by kmemleak. Restore the missing code, and the memory leak is removed. Fixes: ba8c931 ("cdc-acm: refactor killing urbs") Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Acked-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 821c42e commit c92e73b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/usb/class/cdc-acm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ static void acm_disconnect(struct usb_interface *intf)
15271527
{
15281528
struct acm *acm = usb_get_intfdata(intf);
15291529
struct tty_struct *tty;
1530+
int i;
15301531

15311532
/* sibling interface is already cleaning up */
15321533
if (!acm)
@@ -1557,6 +1558,11 @@ static void acm_disconnect(struct usb_interface *intf)
15571558

15581559
tty_unregister_device(acm_tty_driver, acm->minor);
15591560

1561+
usb_free_urb(acm->ctrlurb);
1562+
for (i = 0; i < ACM_NW; i++)
1563+
usb_free_urb(acm->wb[i].urb);
1564+
for (i = 0; i < acm->rx_buflimit; i++)
1565+
usb_free_urb(acm->read_urbs[i]);
15601566
acm_write_buffers_free(acm);
15611567
usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
15621568
acm_read_buffers_free(acm);

0 commit comments

Comments
 (0)