[U-Boot] [PATCH] usb: dwc3: fixes crash in dwc3 driver due to types size mismatch
B, Ravi
ravibabu at ti.com
Thu Jul 21 15:03:25 CEST 2016
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 ?
Yeah, I agree. Compiler not complaining, may be due to fallback to old definitions (32 bit) of resource_size_t because of right header file is not included.
Regards
Ravi
More information about the U-Boot
mailing list