From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 21 Jul 2016 15:05:10 +0200 Subject: [U-Boot] [PATCH] usb: dwc3: fixes crash in dwc3 driver due to types size mismatch In-Reply-To: <6C6B28D4DC342643927BEAFCE8707BF67629D73E@DBDE04.ent.ti.com> References: <1469097666-2758-1-git-send-email-ravibabu@ti.com> <23f5352b-213a-05fa-66b0-4c3d78073824@denx.de> <6C6B28D4DC342643927BEAFCE8707BF67629D4A6@DBDE04.ent.ti.com> <0b93923c-2343-c7b6-dc02-649175ef88a1@denx.de> <6C6B28D4DC342643927BEAFCE8707BF67629D5AC@DBDE04.ent.ti.com> <6C6B28D4DC342643927BEAFCE8707BF67629D73E@DBDE04.ent.ti.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 07/21/2016 03:03 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 ? > > 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. Well please look into it and properly explain why this happens. And fix your damned mailer ! > Regards > Ravi > -- Best regards, Marek Vasut