]> git.karo-electronics.de Git - karo-tx-linux.git/commit
USB: cdc-acm: fix resource reclaim in error path of acm_probe
authorAxel Lin <axel.lin@gmail.com>
Mon, 31 May 2010 00:04:47 +0000 (08:04 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Jul 2010 18:22:49 +0000 (11:22 -0700)
commitf4723b721570bc97eeddc6c4aeea1e2be9f09afb
tree5f3f2ae7c3b321fc7a33cd0c12975d96ea246c59
parent7fcd12387f790caf53fc88bf57c443a9af9f2332
USB: cdc-acm: fix resource reclaim in error path of acm_probe

commit c2572b78aa0447244a38e555ebb1b3b48a0088a5 upstream.

This patch fixes resource reclaim in error path of acm_probe:

1. In the case of "out of memory (read urbs usb_alloc_urb)\n")", there
   is no need to call acm_read_buffers_free(acm) here.  Fix it by goto
   alloc_fail6 instead of alloc_fail7.
2. In the case of "out of memory (write urbs usb_alloc_urb)",
   usb_alloc_urb may fail in any iteration of the for loop.  Current
   implementation does not properly free allocated snd->urb.  Fix it by
   goto alloc_fail8 instead of alloc_fail7.
3. In the case of device_create_file(&intf->dev,&dev_attr_iCountryCodeRelDate)
   fail, acm->country_codes is kfreed. As a result, device_remove_file
   for dev_attr_wCountryCodes will not be executed in acm_disconnect.
   Fix it by calling device_remove_file for dev_attr_wCountryCodes
   before goto skip_countries.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/cdc-acm.c