summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2011-11-26 23:55:49 +0000
committerBertrik Sikken <bertrik@sikken.nl>2011-11-26 23:55:49 +0000
commitebde2ea3082040e4a8e43c7354942ee90e61eb2d (patch)
treeb592d662dfe2f68725d352977ccd2a14bdda7ae3 /firmware/target/arm/as3525
parentfc81af98ee6798814fbd896e4ff44f0cd4eb3d6f (diff)
Sansa AMSv2: potential USB fix from FS#11664 by funman:
* make sure that the buffer for struct usb_ctrlrequest can fit a full 64-byte packet * align struct usb_ctrlrequest to a cacheline (32-byte alignment) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31063 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525v2.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525v2.c b/firmware/target/arm/as3525/usb-drv-as3525v2.c
index 35b50d21cf..3d4f1579c5 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525v2.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525v2.c
@@ -87,8 +87,23 @@ enum ep0state
/* endpoints[ep_num][DIR_IN/DIR_OUT] */
static struct usb_endpoint endpoints[USB_NUM_ENDPOINTS][2];
/* setup packet for EP0 */
-static struct usb_ctrlrequest _ep0_setup_pkt __attribute__((aligned(32)));
-static struct usb_ctrlrequest *ep0_setup_pkt = AS3525_UNCACHED_ADDR(&_ep0_setup_pkt);
+
+/* USB control requests may be up to 64 bytes in size.
+ Even though we never use anything more than the 8 header bytes,
+ we are required to accept request packets of up to 64 bytes size.
+ Provide buffer space for these additional payload bytes so that
+ e.g. write descriptor requests (which are rejected by us, but the
+ payload is transferred anyway) do not cause memory corruption.
+ Fixes FS#12310. -- Michael Sparmann (theseven) */
+static struct
+{
+ union {
+ struct usb_ctrlrequest header; /* 8 bytes */
+ unsigned char payload[64];
+ };
+} _ep0_setup_pkt USB_DEVBSS_ATTR __attribute__((aligned(32)));
+
+static struct usb_ctrlrequest *ep0_setup_pkt = AS3525_UNCACHED_ADDR(&_ep0_setup_pkt.header);
/* state of EP0 */
static enum ep0state ep0_state;