diff options
author | Pavitrakumar Managutte <pavitra1729@gmail.com> | 2014-10-22 09:54:58 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-10-23 14:57:24 -0400 |
commit | d12a8727171c770990c246f0682f0af7859bb245 (patch) | |
tree | 65f081be3d25e5b85187acbfb46d7a3f2f4fd727 /drivers/usb | |
parent | 1200a82a59b6aa65758ccc92c3447b98c53cd7a2 (diff) |
usb: gadget: function: Remove redundant usb_free_all_descriptors
Removed usb_free_all_descriptors in the bind functions, which
results in double-free corruption of the descriptors on error path.
The usb descriptors are allocated by usb_assign_descriptors.
Signed-off-by: Pavitrakumar Managutte <pavitra1729@gmail.com>
Reviewed-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/function/f_eem.c | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_hid.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_ncm.c | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_obex.c | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_phonet.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_rndis.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_subset.c | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_uac2.c | 10 |
8 files changed, 13 insertions, 13 deletions
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c index 4d8b236ea608..c9e90de5bdd9 100644 --- a/drivers/usb/gadget/function/f_eem.c +++ b/drivers/usb/gadget/function/f_eem.c | |||
@@ -325,7 +325,6 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
325 | return 0; | 325 | return 0; |
326 | 326 | ||
327 | fail: | 327 | fail: |
328 | usb_free_all_descriptors(f); | ||
329 | if (eem->port.out_ep) | 328 | if (eem->port.out_ep) |
330 | eem->port.out_ep->driver_data = NULL; | 329 | eem->port.out_ep->driver_data = NULL; |
331 | if (eem->port.in_ep) | 330 | if (eem->port.in_ep) |
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index a95290a1289f..59ab62c92b66 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c | |||
@@ -621,12 +621,14 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
621 | dev = MKDEV(major, hidg->minor); | 621 | dev = MKDEV(major, hidg->minor); |
622 | status = cdev_add(&hidg->cdev, dev, 1); | 622 | status = cdev_add(&hidg->cdev, dev, 1); |
623 | if (status) | 623 | if (status) |
624 | goto fail; | 624 | goto fail_free_descs; |
625 | 625 | ||
626 | device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor); | 626 | device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor); |
627 | 627 | ||
628 | return 0; | 628 | return 0; |
629 | 629 | ||
630 | fail_free_descs: | ||
631 | usb_free_all_descriptors(f); | ||
630 | fail: | 632 | fail: |
631 | ERROR(f->config->cdev, "hidg_bind FAILED\n"); | 633 | ERROR(f->config->cdev, "hidg_bind FAILED\n"); |
632 | if (hidg->req != NULL) { | 634 | if (hidg->req != NULL) { |
@@ -635,7 +637,6 @@ fail: | |||
635 | usb_ep_free_request(hidg->in_ep, hidg->req); | 637 | usb_ep_free_request(hidg->in_ep, hidg->req); |
636 | } | 638 | } |
637 | 639 | ||
638 | usb_free_all_descriptors(f); | ||
639 | return status; | 640 | return status; |
640 | } | 641 | } |
641 | 642 | ||
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 146f48cc65d7..16361b0a8b46 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c | |||
@@ -1461,7 +1461,6 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1461 | return 0; | 1461 | return 0; |
1462 | 1462 | ||
1463 | fail: | 1463 | fail: |
1464 | usb_free_all_descriptors(f); | ||
1465 | if (ncm->notify_req) { | 1464 | if (ncm->notify_req) { |
1466 | kfree(ncm->notify_req->buf); | 1465 | kfree(ncm->notify_req->buf); |
1467 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1466 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index 1a1a490415f4..a1b79c53499c 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c | |||
@@ -397,7 +397,6 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
397 | return 0; | 397 | return 0; |
398 | 398 | ||
399 | fail: | 399 | fail: |
400 | usb_free_all_descriptors(f); | ||
401 | /* we might as well release our claims on endpoints */ | 400 | /* we might as well release our claims on endpoints */ |
402 | if (obex->port.out) | 401 | if (obex->port.out) |
403 | obex->port.out->driver_data = NULL; | 402 | obex->port.out->driver_data = NULL; |
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c index b9cfc1571d71..1ec8b7ffdccd 100644 --- a/drivers/usb/gadget/function/f_phonet.c +++ b/drivers/usb/gadget/function/f_phonet.c | |||
@@ -570,8 +570,8 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f) | |||
570 | err_req: | 570 | err_req: |
571 | for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) | 571 | for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) |
572 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); | 572 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); |
573 | err: | ||
574 | usb_free_all_descriptors(f); | 573 | usb_free_all_descriptors(f); |
574 | err: | ||
575 | if (fp->out_ep) | 575 | if (fp->out_ep) |
576 | fp->out_ep->driver_data = NULL; | 576 | fp->out_ep->driver_data = NULL; |
577 | if (fp->in_ep) | 577 | if (fp->in_ep) |
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index ddb09dc6d1f2..2f0517f5bae3 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c | |||
@@ -803,7 +803,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
803 | if (rndis->manufacturer && rndis->vendorID && | 803 | if (rndis->manufacturer && rndis->vendorID && |
804 | rndis_set_param_vendor(rndis->config, rndis->vendorID, | 804 | rndis_set_param_vendor(rndis->config, rndis->vendorID, |
805 | rndis->manufacturer)) | 805 | rndis->manufacturer)) |
806 | goto fail; | 806 | goto fail_free_descs; |
807 | 807 | ||
808 | /* NOTE: all that is done without knowing or caring about | 808 | /* NOTE: all that is done without knowing or caring about |
809 | * the network link ... which is unavailable to this code | 809 | * the network link ... which is unavailable to this code |
@@ -817,10 +817,11 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
817 | rndis->notify->name); | 817 | rndis->notify->name); |
818 | return 0; | 818 | return 0; |
819 | 819 | ||
820 | fail_free_descs: | ||
821 | usb_free_all_descriptors(f); | ||
820 | fail: | 822 | fail: |
821 | kfree(f->os_desc_table); | 823 | kfree(f->os_desc_table); |
822 | f->os_desc_n = 0; | 824 | f->os_desc_n = 0; |
823 | usb_free_all_descriptors(f); | ||
824 | 825 | ||
825 | if (rndis->notify_req) { | 826 | if (rndis->notify_req) { |
826 | kfree(rndis->notify_req->buf); | 827 | kfree(rndis->notify_req->buf); |
diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c index 1ea8baf33333..e3dfa675ff06 100644 --- a/drivers/usb/gadget/function/f_subset.c +++ b/drivers/usb/gadget/function/f_subset.c | |||
@@ -380,7 +380,6 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
380 | return 0; | 380 | return 0; |
381 | 381 | ||
382 | fail: | 382 | fail: |
383 | usb_free_all_descriptors(f); | ||
384 | /* we might as well release our claims on endpoints */ | 383 | /* we might as well release our claims on endpoints */ |
385 | if (geth->port.out_ep) | 384 | if (geth->port.out_ep) |
386 | geth->port.out_ep->driver_data = NULL; | 385 | geth->port.out_ep->driver_data = NULL; |
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 9296e598428c..33e16658e5cf 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
@@ -1084,7 +1084,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1084 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); | 1084 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); |
1085 | if (!prm->rbuf) { | 1085 | if (!prm->rbuf) { |
1086 | prm->max_psize = 0; | 1086 | prm->max_psize = 0; |
1087 | goto err; | 1087 | goto err_free_descs; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | prm = &agdev->uac2.p_prm; | 1090 | prm = &agdev->uac2.p_prm; |
@@ -1092,17 +1092,19 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1092 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); | 1092 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); |
1093 | if (!prm->rbuf) { | 1093 | if (!prm->rbuf) { |
1094 | prm->max_psize = 0; | 1094 | prm->max_psize = 0; |
1095 | goto err; | 1095 | goto err_free_descs; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | ret = alsa_uac2_init(agdev); | 1098 | ret = alsa_uac2_init(agdev); |
1099 | if (ret) | 1099 | if (ret) |
1100 | goto err; | 1100 | goto err_free_descs; |
1101 | return 0; | 1101 | return 0; |
1102 | |||
1103 | err_free_descs: | ||
1104 | usb_free_all_descriptors(fn); | ||
1102 | err: | 1105 | err: |
1103 | kfree(agdev->uac2.p_prm.rbuf); | 1106 | kfree(agdev->uac2.p_prm.rbuf); |
1104 | kfree(agdev->uac2.c_prm.rbuf); | 1107 | kfree(agdev->uac2.c_prm.rbuf); |
1105 | usb_free_all_descriptors(fn); | ||
1106 | if (agdev->in_ep) | 1108 | if (agdev->in_ep) |
1107 | agdev->in_ep->driver_data = NULL; | 1109 | agdev->in_ep->driver_data = NULL; |
1108 | if (agdev->out_ep) | 1110 | if (agdev->out_ep) |