From f871e539ed9453a9a4e93847a39d23e5a28acea5 Mon Sep 17 00:00:00 2001 From: Sebastian Holzapfel Date: Sun, 11 Feb 2018 09:39:55 +1100 Subject: [PATCH] usb-standard: fix alignment assumption for Cortex-M0 platforms --- lib/usb/usb_standard.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/usb/usb_standard.c b/lib/usb/usb_standard.c index d94ceed9..d927942f 100644 --- a/lib/usb/usb_standard.c +++ b/lib/usb/usb_standard.c @@ -129,8 +129,9 @@ static uint16_t build_config_descriptor(usbd_device *usbd_dev, } } - /* Fill in wTotalLength. */ - *(uint16_t *)(tmpbuf + 2) = totallen; + /* Fill in wTotalLength. + * Note that tmpbuf is sometimes not halfword-aligned */ + memcpy((tmpbuf + 2), &totallen, sizeof(uint16_t)); return total; }