Commit 56bebe70bd3659e046e6a6be08492061fedd1ad1
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 | 91 | case 0: |
92 | 92 | switch(s->setup_state) { |
93 | 93 | case SETUP_STATE_ACK: |
94 | - s->setup_state = SETUP_STATE_IDLE; | |
95 | 94 | if (!(s->setup_buf[0] & USB_DIR_IN)) { |
95 | + s->setup_state = SETUP_STATE_IDLE; | |
96 | 96 | ret = s->handle_control(s, |
97 | 97 | (s->setup_buf[0] << 8) | s->setup_buf[1], |
98 | 98 | (s->setup_buf[3] << 8) | s->setup_buf[2], |
... | ... | @@ -102,7 +102,7 @@ int usb_generic_handle_packet(USBDevice *s, int pid, |
102 | 102 | if (ret > 0) |
103 | 103 | ret = 0; |
104 | 104 | } else { |
105 | - goto fail; | |
105 | + /* return 0 byte */ | |
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case SETUP_STATE_DATA: |
... | ... | @@ -136,11 +136,11 @@ int usb_generic_handle_packet(USBDevice *s, int pid, |
136 | 136 | case 0: |
137 | 137 | switch(s->setup_state) { |
138 | 138 | case SETUP_STATE_ACK: |
139 | - s->setup_state = SETUP_STATE_IDLE; | |
140 | 139 | if (s->setup_buf[0] & USB_DIR_IN) { |
140 | + s->setup_state = SETUP_STATE_IDLE; | |
141 | 141 | /* transfer OK */ |
142 | 142 | } else { |
143 | - goto fail; | |
143 | + /* ignore additionnal output */ | |
144 | 144 | } |
145 | 145 | break; |
146 | 146 | case SETUP_STATE_DATA: | ... | ... |