Commit 56bebe70bd3659e046e6a6be08492061fedd1ad1

Authored by bellard
1 parent fd4a43e4

usb setup state machine fix when driver reads or writes too many bytes


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1847 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 4 additions and 4 deletions
hw/usb.c
@@ -91,8 +91,8 @@ int usb_generic_handle_packet(USBDevice *s, int pid, @@ -91,8 +91,8 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
91 case 0: 91 case 0:
92 switch(s->setup_state) { 92 switch(s->setup_state) {
93 case SETUP_STATE_ACK: 93 case SETUP_STATE_ACK:
94 - s->setup_state = SETUP_STATE_IDLE;  
95 if (!(s->setup_buf[0] & USB_DIR_IN)) { 94 if (!(s->setup_buf[0] & USB_DIR_IN)) {
  95 + s->setup_state = SETUP_STATE_IDLE;
96 ret = s->handle_control(s, 96 ret = s->handle_control(s,
97 (s->setup_buf[0] << 8) | s->setup_buf[1], 97 (s->setup_buf[0] << 8) | s->setup_buf[1],
98 (s->setup_buf[3] << 8) | s->setup_buf[2], 98 (s->setup_buf[3] << 8) | s->setup_buf[2],
@@ -102,7 +102,7 @@ int usb_generic_handle_packet(USBDevice *s, int pid, @@ -102,7 +102,7 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
102 if (ret > 0) 102 if (ret > 0)
103 ret = 0; 103 ret = 0;
104 } else { 104 } else {
105 - goto fail; 105 + /* return 0 byte */
106 } 106 }
107 break; 107 break;
108 case SETUP_STATE_DATA: 108 case SETUP_STATE_DATA:
@@ -136,11 +136,11 @@ int usb_generic_handle_packet(USBDevice *s, int pid, @@ -136,11 +136,11 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
136 case 0: 136 case 0:
137 switch(s->setup_state) { 137 switch(s->setup_state) {
138 case SETUP_STATE_ACK: 138 case SETUP_STATE_ACK:
139 - s->setup_state = SETUP_STATE_IDLE;  
140 if (s->setup_buf[0] & USB_DIR_IN) { 139 if (s->setup_buf[0] & USB_DIR_IN) {
  140 + s->setup_state = SETUP_STATE_IDLE;
141 /* transfer OK */ 141 /* transfer OK */
142 } else { 142 } else {
143 - goto fail; 143 + /* ignore additionnal output */
144 } 144 }
145 break; 145 break;
146 case SETUP_STATE_DATA: 146 case SETUP_STATE_DATA: