From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Wed, 17 Jul 2013 05:05:17 +0200 Subject: [U-Boot] [PATCH RFC V1 06/18] usb: gadget: config: fix unaligned access issues In-Reply-To: <1374007666-2749-7-git-send-email-troy.kisky@boundarydevices.com> References: <1374007666-2749-1-git-send-email-troy.kisky@boundarydevices.com> <1374007666-2749-7-git-send-email-troy.kisky@boundarydevices.com> Message-ID: <201307170505.18043.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, Missing commit message :-( > 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 f9163a8..a4cb5ad 100644 > --- a/drivers/usb/gadget/config.c > +++ b/drivers/usb/gadget/config.c > @@ -22,6 +22,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -98,7 +99,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, > @@ -112,7 +114,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; > } Best regards, Marek Vasut