summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-10-18 11:42:00 +0700
committerhathach <[email protected]>2021-10-18 11:42:00 +0700
commit6fcf4bee8c1540618b5d8d8709ef76cd2aa1c66f (patch)
tree3244b75ed6fe301836e5dc58b67d1d82724b559d /src/host
parenta7dd5b616cb95a4e395a148fcd2f761ce23a8faf (diff)
suppress null-dereference by usbh and lwip
Diffstat (limited to 'src/host')
-rw-r--r--src/host/usbh.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 53e8b9715..a9c2c201f 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -53,13 +53,39 @@
// USBH-HCD common data structure
//--------------------------------------------------------------------+
+// device0 struct must be strictly a subset of normal device struct
+typedef struct
+{
+ // port
+ uint8_t rhport;
+ uint8_t hub_addr;
+ uint8_t hub_port;
+ uint8_t speed;
+
+ volatile struct TU_ATTR_PACKED
+ {
+ uint8_t connected : 1;
+ uint8_t addressed : 1;
+ uint8_t configured : 1;
+ uint8_t suspended : 1;
+ };
+} usbh_dev0_t;
+
typedef struct {
- //------------- port -------------//
+ // port
uint8_t rhport;
uint8_t hub_addr;
uint8_t hub_port;
uint8_t speed;
+ volatile struct TU_ATTR_PACKED
+ {
+ uint8_t connected : 1;
+ uint8_t addressed : 1;
+ uint8_t configured : 1;
+ uint8_t suspended : 1;
+ };
+
//------------- device descriptor -------------//
uint16_t vid;
uint16_t pid;
@@ -73,14 +99,6 @@ typedef struct {
// uint8_t interface_count; // bNumInterfaces alias
//------------- device -------------//
- struct TU_ATTR_PACKED
- {
- uint8_t connected : 1;
- uint8_t addressed : 1;
- uint8_t configured : 1;
- uint8_t suspended : 1;
- };
-
volatile uint8_t state; // device state, value from enum tusbh_device_state_t
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
@@ -103,16 +121,6 @@ typedef struct {
} usbh_device_t;
-typedef struct
-{
- uint8_t rhport;
- uint8_t hub_addr;
- uint8_t hub_port;
- uint8_t speed;
-
- volatile uint8_t connected;
-} usbh_dev0_t;
-
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF