From patchwork Wed Nov 9 21:09:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5008 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 346ED23E0E for ; Wed, 9 Nov 2011 21:09:29 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1A328A1817C for ; Wed, 9 Nov 2011 21:09:29 +0000 (UTC) Received: by faan26 with SMTP id n26so3013544faa.11 for ; Wed, 09 Nov 2011 13:09:29 -0800 (PST) Received: by 10.152.102.138 with SMTP id fo10mr2727726lab.44.1320872968850; Wed, 09 Nov 2011 13:09:28 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.10.72 with SMTP id g8cs187462lab; Wed, 9 Nov 2011 13:09:28 -0800 (PST) Received: by 10.216.24.79 with SMTP id w57mr679157wew.91.1320872966577; Wed, 09 Nov 2011 13:09:26 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id c58si3466418wed.5.2011.11.09.13.09.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Nov 2011 13:09:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1ROFOd-0002iD-Fc; Wed, 09 Nov 2011 21:09:23 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Gerd Hoffmann Subject: [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state Date: Wed, 9 Nov 2011 21:09:23 +0000 Message-Id: <1320872963-10402-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 "!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 --- NB that although I tested that this doesn't break non-rndis usb-net, I don't have a test image that uses rndis usb-net, so treat this patch with the appropriate degree of caution. (Probably safer not putting it into 1.0 unless tested.) hw/usb-net.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/usb-net.c b/hw/usb-net.c index a8b7c8d..f91fa32 100644 --- a/hw/usb-net.c +++ b/hw/usb-net.c @@ -1268,8 +1268,9 @@ static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t si if (is_rndis(s)) { msg = (struct rndis_packet_msg_type *) s->in_buf; - if (!s->rndis_state == RNDIS_DATA_INITIALIZED) + if (s->rndis_state != RNDIS_DATA_INITIALIZED) { return -1; + } if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf)) return -1; @@ -1302,7 +1303,7 @@ static int usbnet_can_receive(VLANClientState *nc) { USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; - if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) { + if (is_rndis(s) && s->rndis_state != RNDIS_DATA_INITIALIZED) { return 1; }