diff mbox series

driver: gadget: fastboot: Link endpoint and descriptors

Message ID 20210916070236.26944-1-qianfanguijin@163.com
State Changes Requested
Delegated to: Sean Anderson
Headers show
Series driver: gadget: fastboot: Link endpoint and descriptors | expand

Commit Message

qianfan Sept. 16, 2021, 7:02 a.m. UTC
From: qianfan Zhao <qianfanguijin@163.com>

If the downloading file size is equal to the partition size, "fastboot
flash" can't work, at least in sunxi platform, because used an
uninitalized point: ep->desc.

Reproduce: fastboot flash loader1 spl/sunxi-spl.bin.

Fix it.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 drivers/usb/gadget/f_fastboot.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Sean Anderson Nov. 3, 2021, 4:53 p.m. UTC | #1
On 9/16/21 3:02 AM, qianfanguijin@163.com wrote:
> From: qianfan Zhao <qianfanguijin@163.com>
> 
> If the downloading file size is equal to the partition size, "fastboot
> flash" can't work, at least in sunxi platform, because used an
> uninitalized point: ep->desc.

Hm, I think that usb_ep_ops->enable needs to set ep->desc = desc on success.

Of the existing drivers, only musb-new and mtu3 skip this.

--Sean
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 8ba55aab9f..45bb3aba66 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -319,13 +319,13 @@  static int fastboot_set_alt(struct usb_function *f,
 	struct usb_composite_dev *cdev = f->config->cdev;
 	struct usb_gadget *gadget = cdev->gadget;
 	struct f_fastboot *f_fb = func_to_fastboot(f);
-	const struct usb_endpoint_descriptor *d;
 
 	debug("%s: func: %s intf: %d alt: %d\n",
 	      __func__, f->name, interface, alt);
 
-	d = fb_ep_desc(gadget, &fs_ep_out, &hs_ep_out, &ss_ep_out);
-	ret = usb_ep_enable(f_fb->out_ep, d);
+	f_fb->out_ep->desc = fb_ep_desc(gadget, &fs_ep_out, &hs_ep_out,
+					&ss_ep_out);
+	ret = usb_ep_enable(f_fb->out_ep, f_fb->out_ep->desc);
 	if (ret) {
 		puts("failed to enable out ep\n");
 		return ret;
@@ -339,8 +339,8 @@  static int fastboot_set_alt(struct usb_function *f,
 	}
 	f_fb->out_req->complete = rx_handler_command;
 
-	d = fb_ep_desc(gadget, &fs_ep_in, &hs_ep_in, &ss_ep_in);
-	ret = usb_ep_enable(f_fb->in_ep, d);
+	f_fb->in_ep->desc = fb_ep_desc(gadget, &fs_ep_in, &hs_ep_in, &ss_ep_in);
+	ret = usb_ep_enable(f_fb->in_ep, f_fb->in_ep->desc);
 	if (ret) {
 		puts("failed to enable in ep\n");
 		goto err;