Commit e5fd39d9 authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Greg Kroah-Hartman

USB: gadget: f_mass_storage: fixed fs descriptors not being updated

The full speed descriptors were copied to the usb_function structure
in the fsg_bind_config function before call to the usb_ep_autoconfig.
The usb_ep_autoconfig was called in fsg_bind using the original
descriptors.  In effect copied descriptors were not updated.

This patch changes the copy full speed descriptors after the call to
usb_op_autoconfig is performed.  This way, copied full speed
descriptors have updated values.
Signed-off-by: default avatarMichal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Reported-by: default avatarDries Van Puymbroeck <Dries.VanPuymbroeck@dekimo.com>
Tested-by: default avatarDries Van Puymbroeck <Dries.VanPuymbroeck@dekimo.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c0f1f8e3
...@@ -2970,7 +2970,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -2970,7 +2970,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
{ {
struct fsg_dev *fsg = fsg_from_func(f); struct fsg_dev *fsg = fsg_from_func(f);
struct usb_gadget *gadget = c->cdev->gadget; struct usb_gadget *gadget = c->cdev->gadget;
int rc;
int i; int i;
struct usb_ep *ep; struct usb_ep *ep;
...@@ -2996,6 +2995,11 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -2996,6 +2995,11 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
ep->driver_data = fsg->common; /* claim the endpoint */ ep->driver_data = fsg->common; /* claim the endpoint */
fsg->bulk_out = ep; fsg->bulk_out = ep;
/* Copy descriptors */
f->descriptors = usb_copy_descriptors(fsg_fs_function);
if (unlikely(!f->descriptors))
return -ENOMEM;
if (gadget_is_dualspeed(gadget)) { if (gadget_is_dualspeed(gadget)) {
/* Assume endpoint addresses are the same for both speeds */ /* Assume endpoint addresses are the same for both speeds */
fsg_hs_bulk_in_desc.bEndpointAddress = fsg_hs_bulk_in_desc.bEndpointAddress =
...@@ -3003,16 +3007,17 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -3003,16 +3007,17 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
fsg_hs_bulk_out_desc.bEndpointAddress = fsg_hs_bulk_out_desc.bEndpointAddress =
fsg_fs_bulk_out_desc.bEndpointAddress; fsg_fs_bulk_out_desc.bEndpointAddress;
f->hs_descriptors = usb_copy_descriptors(fsg_hs_function); f->hs_descriptors = usb_copy_descriptors(fsg_hs_function);
if (unlikely(!f->hs_descriptors)) if (unlikely(!f->hs_descriptors)) {
usb_free_descriptors(f->descriptors);
return -ENOMEM; return -ENOMEM;
}
} }
return 0; return 0;
autoconf_fail: autoconf_fail:
ERROR(fsg, "unable to autoconfigure all endpoints\n"); ERROR(fsg, "unable to autoconfigure all endpoints\n");
rc = -ENOTSUPP; return -ENOTSUPP;
return rc;
} }
...@@ -3036,11 +3041,6 @@ static int fsg_add(struct usb_composite_dev *cdev, ...@@ -3036,11 +3041,6 @@ static int fsg_add(struct usb_composite_dev *cdev,
fsg->function.name = FSG_DRIVER_DESC; fsg->function.name = FSG_DRIVER_DESC;
fsg->function.strings = fsg_strings_array; fsg->function.strings = fsg_strings_array;
fsg->function.descriptors = usb_copy_descriptors(fsg_fs_function);
if (unlikely(!fsg->function.descriptors)) {
rc = -ENOMEM;
goto error_free_fsg;
}
fsg->function.bind = fsg_bind; fsg->function.bind = fsg_bind;
fsg->function.unbind = fsg_unbind; fsg->function.unbind = fsg_unbind;
fsg->function.setup = fsg_setup; fsg->function.setup = fsg_setup;
...@@ -3056,19 +3056,9 @@ static int fsg_add(struct usb_composite_dev *cdev, ...@@ -3056,19 +3056,9 @@ static int fsg_add(struct usb_composite_dev *cdev,
rc = usb_add_function(c, &fsg->function); rc = usb_add_function(c, &fsg->function);
if (unlikely(rc)) if (unlikely(rc))
goto error_free_all; kfree(fsg);
else
fsg_common_get(fsg->common); fsg_common_get(fsg->common);
return 0;
error_free_all:
usb_free_descriptors(fsg->function.descriptors);
/* fsg_bind() might have copied those; or maybe not? who cares
* -- free it just in case. */
usb_free_descriptors(fsg->function.hs_descriptors);
error_free_fsg:
kfree(fsg);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment