From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Fri, 2 Aug 2013 01:27:45 +0200 Subject: [U-Boot] [PATCH V2 06/20] usb: gadget: config: fix unaligned access issues In-Reply-To: <51FAEBC7.5090406@boundarydevices.com> References: <1375395521-18569-1-git-send-email-troy.kisky@boundarydevices.com> <201308020055.22930.marex@denx.de> <51FAEBC7.5090406@boundarydevices.com> Message-ID: <201308020127.45919.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Troy Kisky, > On 8/1/2013 3:55 PM, Marek Vasut wrote: > > Dear Troy Kisky, > > > >> On 8/1/2013 3:18 PM, Troy Kisky wrote: > >>> Signed-off-by: Troy Kisky > >>> --- > >>> > >>> drivers/usb/gadget/config.c | 6 ++++-- > >>> 1 file changed, 4 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c > >>> index f563afe..014a679 100644 > >>> --- a/drivers/usb/gadget/config.c > >>> +++ b/drivers/usb/gadget/config.c > >>> @@ -10,6 +10,7 @@ > >>> > >>> */ > >>> > >>> #include > >>> > >>> +#include > >>> > >>> #include > >>> #include > >>> #include > >>> > >>> @@ -86,7 +87,8 @@ int usb_gadget_config_buf( > >>> > >>> /* config descriptor first */ > >>> if (length < USB_DT_CONFIG_SIZE || !desc) > >>> > >>> return -EINVAL; > >>> > >>> - *cp = *config; > >>> + /* config need not be aligned */ > >>> + memcpy(cp, config, sizeof(*cp)); > >>> > >>> /* then interface/endpoint/class/vendor/... */ > >>> len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf, > >>> > >>> @@ -100,7 +102,7 @@ int usb_gadget_config_buf( > >>> > >>> /* patch up the config descriptor */ > >>> cp->bLength = USB_DT_CONFIG_SIZE; > >>> cp->bDescriptorType = USB_DT_CONFIG; > >>> > >>> - cp->wTotalLength = cpu_to_le16(len); > >>> + put_unaligned_le16(len, &cp->wTotalLength); > >>> > >>> cp->bmAttributes |= USB_CONFIG_ATT_ONE; > >>> return len; > >>> > >>> } > >> > >> Sorry folks, I forgot to delete old patches when I rebased to put > >> Stefano patches together, please ignore this one. > > > > Repost the series please, this is really hard to review. > > > > Best regards, > > Marek Vasut > > Yes, will do a V3 to clear things up. > > Troy Thanks a lot! Best regards, Marek Vasut