diff mbox

[U-Boot] usb: gadget: f_thor: Allocate request up to THOR_PACKET_SIZE

Message ID 852fe9de-b219-4301-bb9a-e9dd023abd8d@BL2FFO11FD041.protection.gbl
State Accepted
Delegated to: Ɓukasz Majewski
Headers show

Commit Message

Siva Durga Prasad Paladugu Sept. 5, 2014, 10:09 a.m. UTC
Allocate request up to THOR_PACKET_SIZE not the ep0->maxpacket
as the descriptors data depend on the number of descriptors
and this 64 bytes were not enough and the buffer might overflow
which results in memalign failures later.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
---
 drivers/usb/gadget/f_thor.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Michal Simek Sept. 24, 2014, 12:28 p.m. UTC | #1
On 09/05/2014 12:09 PM, Siva Durga Prasad Paladugu wrote:
> Allocate request up to THOR_PACKET_SIZE not the ep0->maxpacket
> as the descriptors data depend on the number of descriptors
> and this 64 bytes were not enough and the buffer might overflow
> which results in memalign failures later.
> 
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> ---
>  drivers/usb/gadget/f_thor.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index c85b0fb..98d2d8c 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -766,7 +766,7 @@ static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
>  		goto fail;
>  	}
>  	dev->req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
> -				 gadget->ep0->maxpacket);
> +				 THOR_PACKET_SIZE);
>  	if (!dev->req->buf) {
>  		status = -ENOMEM;
>  		goto fail;
> 

Tested-by: Michal Simek <monstr@monstr.eu>

Thanks,
Michal
Michal Simek April 15, 2015, 11:01 a.m. UTC | #2
Hi Marek,

2014-09-24 14:28 GMT+02:00 Michal Simek <monstr@monstr.eu>:

> On 09/05/2014 12:09 PM, Siva Durga Prasad Paladugu wrote:
> > Allocate request up to THOR_PACKET_SIZE not the ep0->maxpacket
> > as the descriptors data depend on the number of descriptors
> > and this 64 bytes were not enough and the buffer might overflow
> > which results in memalign failures later.
> >
> > Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> > ---
> >  drivers/usb/gadget/f_thor.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> > index c85b0fb..98d2d8c 100644
> > --- a/drivers/usb/gadget/f_thor.c
> > +++ b/drivers/usb/gadget/f_thor.c
> > @@ -766,7 +766,7 @@ static int thor_func_bind(struct usb_configuration
> *c, struct usb_function *f)
> >               goto fail;
> >       }
> >       dev->req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
> > -                              gadget->ep0->maxpacket);
> > +                              THOR_PACKET_SIZE);
> >       if (!dev->req->buf) {
> >               status = -ENOMEM;
> >               goto fail;
> >
>
> Tested-by: Michal Simek <monstr@monstr.eu>
>
> Thanks,
> Michal
>
>
Any update on this one?

Thanks,
Michal
diff mbox

Patch

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index c85b0fb..98d2d8c 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -766,7 +766,7 @@  static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
 		goto fail;
 	}
 	dev->req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
-				 gadget->ep0->maxpacket);
+				 THOR_PACKET_SIZE);
 	if (!dev->req->buf) {
 		status = -ENOMEM;
 		goto fail;