]> bbs.cooldavid.org Git - net-next-2.6.git/commit
usb: subtle increased memory usage in u_serial
authorJim Sung <jsung@syncadence.com>
Fri, 5 Nov 2010 01:47:51 +0000 (18:47 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 11 Nov 2010 15:03:48 +0000 (07:03 -0800)
commit28609d4083bcd4879e951b0c4ecf4c3a88761261
treec5b5863370ca4ee125e44ffcaa5f1afe86986fdf
parent58c0d9d70109bd7e82bdb9517007311a48499960
usb: subtle increased memory usage in u_serial

OK, the USB gadget serial driver actually has a couple of problems.  On
gs_open(), it always allocates and queues an additional QUEUE_SIZE (16)
worth of requests, so with a loop like this:

    i=1 ; while echo $i > /dev/ttyGS0 ; do let i++ ; done

eventually we run into OOM (Out of Memory).

Technically, it is not a leak as everything gets freed up when the USB
connection is broken, but not on gs_close().

With a USB device/gadget controller driver that has limited resources
(e.g., Marvell has a this MAX_XDS_FOR_TR_CALLS of 64 for transmit and
receive), so even after 4

    stty -F /dev/ttyGS0

we cannot transmit anymore.  We can still receive (not necessarily
reliably) as now we have 16 * 4 = 64 descriptors/buffers ready, but the
device is otherwise not usable.

Signed-off-by: Jim Sung <jsung@syncadence.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/u_serial.c