[U-Boot] [PATCH] usb: dwc3: fixes crash in dwc3 driver due to types size mismatch

Marek Vasut marex at denx.de
Thu Jul 21 14:54:33 CEST 2016


On 07/21/2016 02:44 PM, B, Ravi wrote:
> Hi Marek
>  
>>>> Please explain why this patch fixes the issue.
>>>
>>> Ok I will explain, due to the commit[1] the resource_size_t size has increased to 8 bytes (64 bit), compared to earlier 32 bit (4bytes) and the definition is moved to includes/linux/types.h from asm.h. Due to this change the code generated in gadget.c is correct, due >to inclusion of right header file (common.h, which includes linux/types.h). Whereas, the ep0.c does not includes common.h, hence  size of resources_size_t is 4 bytes, causing wrong offset code generated for structure members which includes resource_size_t, which >leads to pointing to wrong offset location causing the crash.
> 
>> This stuff should be in the commit message. Still, git grep resource_size_t does not show that it's used in gadget.c , so I don't understand how this patch can fix things.
> 
> Thanks, I will add this text to commit message. The resource_size_t is used in dwc3 structure
> defined in drivers/usb/dwc3/core.h
> 
> struct dwc3 {
> 	....
> 	struct resource  xhci_resource[DWC3_XHCI_RESOURCES_NUM];
> 	..
> };
> The resource structure defined in include/linux/ioport.h 
> struct resource {
> 	resource_size_t start;
> 	resource_size_t end;
> }

OK, I am starting to get a better picture of this issue.
But somehow I suspect there is a deeper problem with the
includes -- how is it possible that the compiler didn't
complain about the resource_size_t being undefined, but
instead used (incorrectly sized) variant ?

>> Also, please fix your mailer to break at 80 chars per line.
> 
> Sure.
> 
> Regards
> Ravi
> 


-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list