From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Luis R. Rodriguez" Subject: [PATCH 3/9] hw/usb-net.c: fix state check Date: Fri, 20 Nov 2015 09:47:46 -0800 Message-ID: <1448041672-3986-4-git-send-email-mcgrof@do-not-panic.com> References: <1448041672-3986-1-git-send-email-mcgrof@do-not-panic.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1448041672-3986-1-git-send-email-mcgrof@do-not-panic.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com, ian.campbell@citrix.com, JBeulich@suse.com Cc: Peter Maydell , Anthony Liguori , "Luis R. Rodriguez" , pryorm09@gmail.com, cfergeau@redhat.com, samuel.thibault@ens-lyon.org List-Id: xen-devel@lists.xenproject.org From: "Luis R. Rodriguez" The existing check is incorrect, currently it will actually allow the code path to move on regardless of the state, fix this. This is fixed upstream on qemu by the following commit: commit 98d23704138e0be17a3ed9eb2631077bf92cc028 Author: Peter Maydell Date: Wed Nov 9 21:09:23 2011 +0000 hw/usb-net.c: Fix precedence bug when checking rndis_state "!X == 2" is always false (spotted by Coverity), so the checks for whether rndis is in the correct state would never fire. Signed-off-by: Peter Maydell Signed-off-by: Anthony Liguori Cc: Peter Maydell Cc: Anthony Liguori Signed-off-by: Luis R. Rodriguez --- hw/usb-net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb-net.c b/hw/usb-net.c index 863c25fd9cb9..b4b0f9409c2f 100644 --- a/hw/usb-net.c +++ b/hw/usb-net.c @@ -1376,7 +1376,7 @@ static void usbnet_receive(void *opaque, const uint8_t *buf, int size) if (s->rndis) { msg = (struct rndis_packet_msg_type *) s->in_buf; - if (!s->rndis_state == RNDIS_DATA_INITIALIZED) + if (s->rndis_state != RNDIS_DATA_INITIALIZED) return; if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf)) return; @@ -1409,7 +1409,7 @@ static int usbnet_can_receive(void *opaque) { USBNetState *s = opaque; - if (s->rndis && !s->rndis_state == RNDIS_DATA_INITIALIZED) + if (s->rndis && s->rndis_state != RNDIS_DATA_INITIALIZED) return 1; return !s->in_len; -- 2.6.2