diff mbox

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

Message ID 0cdbb683a15f4c5d3989aa1758c887f1603c83df.1429098137.git.michal.simek@xilinx.com
State Deferred
Delegated to: Łukasz Majewski
Headers show

Commit Message

Michal Simek April 15, 2015, 11:42 a.m. UTC
From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>

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>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/usb/gadget/f_thor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Łukasz Majewski April 24, 2015, 3:46 p.m. UTC | #1
Hi Michal,

> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> 
> 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>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  drivers/usb/gadget/f_thor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index 31eec36be876..5c8f6768519c 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -775,7 +775,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;

Applied to u-boot-dfu. Thanks!
Michal Simek Aug. 12, 2015, 10:36 a.m. UTC | #2
Hi Lukasz,

On 04/24/2015 05:46 PM, Lukasz Majewski wrote:
> Hi Michal,
> 
>> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>>
>> 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>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>>  drivers/usb/gadget/f_thor.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
>> index 31eec36be876..5c8f6768519c 100644
>> --- a/drivers/usb/gadget/f_thor.c
>> +++ b/drivers/usb/gadget/f_thor.c
>> @@ -775,7 +775,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;
> 
> Applied to u-boot-dfu. Thanks!
> 

I can't see this patch in your branch. Did you add it?

Thanks,
Michal
Łukasz Majewski Aug. 12, 2015, 11:09 a.m. UTC | #3
Hi Michal,

> Hi Lukasz,
> 
> On 04/24/2015 05:46 PM, Lukasz Majewski wrote:
> > Hi Michal,
> > 
> >> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> >>
> >> 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>
> >> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> >> ---
> >>
> >>  drivers/usb/gadget/f_thor.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/usb/gadget/f_thor.c
> >> b/drivers/usb/gadget/f_thor.c index 31eec36be876..5c8f6768519c
> >> 100644 --- a/drivers/usb/gadget/f_thor.c
> >> +++ b/drivers/usb/gadget/f_thor.c
> >> @@ -775,7 +775,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;
> > 
> > Applied to u-boot-dfu. Thanks!
> > 
> 
> I can't see this patch in your branch. Did you add it?

Please look into u-boot-dfu/testing branch.

I've placed them there for testing. Afterwards I will put them to
master branch

> 
> Thanks,
> Michal
>
Michal Simek Aug. 12, 2015, 11:14 a.m. UTC | #4
On 08/12/2015 01:09 PM, Lukasz Majewski wrote:
> Hi Michal,
> 
>> Hi Lukasz,
>>
>> On 04/24/2015 05:46 PM, Lukasz Majewski wrote:
>>> Hi Michal,
>>>
>>>> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>>>>
>>>> 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>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>> ---
>>>>
>>>>  drivers/usb/gadget/f_thor.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/usb/gadget/f_thor.c
>>>> b/drivers/usb/gadget/f_thor.c index 31eec36be876..5c8f6768519c
>>>> 100644 --- a/drivers/usb/gadget/f_thor.c
>>>> +++ b/drivers/usb/gadget/f_thor.c
>>>> @@ -775,7 +775,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;
>>>
>>> Applied to u-boot-dfu. Thanks!
>>>
>>
>> I can't see this patch in your branch. Did you add it?
> 
> Please look into u-boot-dfu/testing branch.
> 
> I've placed them there for testing. Afterwards I will put them to
> master branch

Ok.

Thanks,
Michal
diff mbox

Patch

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 31eec36be876..5c8f6768519c 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -775,7 +775,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;