From f6bb1b339ad30e31b873f1f9c97d64c6a9c9a110 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 29 Aug 2019 17:46:07 +0300 Subject: [PATCH] usb: Guarantee alignment of the string descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit GCC 9.x starts complaining about potential misalignment of the pointer to the array (in this case alignment=2) in the packed (alignment=1) structures. drivers/usb/gadget/composite.c:545:23: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] 545 | collect_langs(sp, s->wData); drivers/usb/gadget/composite.c:550:24: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] 550 | collect_langs(sp, s->wData); drivers/usb/gadget/composite.c:555:25: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] 555 | collect_langs(sp, s->wData); Define structure alignment to be 2 to guarantee alignment of its members. Signed-off-by: Andy Shevchenko Reviewed-by: Bin Meng [sw0312.kim: apply from list https://patchwork.ozlabs.org/patch/1155376/, to remove gcc9 warning] Suggested-by: Jaehoon Chung Signed-off-by: Seung-Woo Kim Change-Id: Id5b0f65266f452458623c49c46dee002c462a3b2 --- include/linux/usb/ch9.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index d9822aa..f9d9dbb 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -290,7 +290,7 @@ struct usb_string_descriptor { __u8 bDescriptorType; __le16 wData[1]; /* UTF-16LE encoded */ -} __attribute__ ((packed)); +} __attribute__ ((packed, aligned(2))); /* note that "string" zero is special, it holds language codes that * the device supports, not Unicode characters. -- 2.7.4