aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-05-30 20:04:47 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-06-04 16:16:19 -0400
commitc2572b78aa0447244a38e555ebb1b3b48a0088a5 (patch)
treec495c12926b27afdc8698a27fca5b17c7d0a9cda /drivers/usb/class
parent6a1a82df91fa0eb1cc76069a9efe5714d087eccd (diff)
USB: cdc-acm: fix resource reclaim in error path of acm_probe
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> Cc: stable <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/class')
-rw-r--r--drivers/usb/class/cdc-acm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0c2f14ff9696..61d75507d5d0 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1201,7 +1201,7 @@ made_compressed_probe:
1201 if (rcv->urb == NULL) { 1201 if (rcv->urb == NULL) {
1202 dev_dbg(&intf->dev, 1202 dev_dbg(&intf->dev,
1203 "out of memory (read urbs usb_alloc_urb)\n"); 1203 "out of memory (read urbs usb_alloc_urb)\n");
1204 goto alloc_fail7; 1204 goto alloc_fail6;
1205 } 1205 }
1206 1206
1207 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1207 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
@@ -1225,7 +1225,7 @@ made_compressed_probe:
1225 if (snd->urb == NULL) { 1225 if (snd->urb == NULL) {
1226 dev_dbg(&intf->dev, 1226 dev_dbg(&intf->dev,
1227 "out of memory (write urbs usb_alloc_urb)"); 1227 "out of memory (write urbs usb_alloc_urb)");
1228 goto alloc_fail7; 1228 goto alloc_fail8;
1229 } 1229 }
1230 1230
1231 if (usb_endpoint_xfer_int(epwrite)) 1231 if (usb_endpoint_xfer_int(epwrite))
@@ -1264,6 +1264,7 @@ made_compressed_probe:
1264 i = device_create_file(&intf->dev, 1264 i = device_create_file(&intf->dev,
1265 &dev_attr_iCountryCodeRelDate); 1265 &dev_attr_iCountryCodeRelDate);
1266 if (i < 0) { 1266 if (i < 0) {
1267 device_remove_file(&intf->dev, &dev_attr_wCountryCodes);
1267 kfree(acm->country_codes); 1268 kfree(acm->country_codes);
1268 goto skip_countries; 1269 goto skip_countries;
1269 } 1270 }
@@ -1300,6 +1301,7 @@ alloc_fail8:
1300 usb_free_urb(acm->wb[i].urb); 1301 usb_free_urb(acm->wb[i].urb);
1301alloc_fail7: 1302alloc_fail7:
1302 acm_read_buffers_free(acm); 1303 acm_read_buffers_free(acm);
1304alloc_fail6:
1303 for (i = 0; i < num_rx_buf; i++) 1305 for (i = 0; i < num_rx_buf; i++)
1304 usb_free_urb(acm->ru[i].urb); 1306 usb_free_urb(acm->ru[i].urb);
1305 usb_free_urb(acm->ctrlurb); 1307 usb_free_urb(acm->ctrlurb);