From patchwork Mon Jul 18 03:29:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 649311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rt7wz5kCLz9s5J for ; Mon, 18 Jul 2016 13:30:43 +1000 (AEST) Received: from localhost ([::1]:44102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOzGR-0003DU-VP for incoming@patchwork.ozlabs.org; Sun, 17 Jul 2016 23:30:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOzFj-0002qr-GW for qemu-devel@nongnu.org; Sun, 17 Jul 2016 23:29:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOzFg-0002nU-8b for qemu-devel@nongnu.org; Sun, 17 Jul 2016 23:29:55 -0400 Received: from ozlabs.ru ([83.169.36.222]:46571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOzFg-0002nH-27 for qemu-devel@nongnu.org; Sun, 17 Jul 2016 23:29:52 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 370BD1205AB; Mon, 18 Jul 2016 05:29:10 +0200 (CEST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Mon, 18 Jul 2016 13:29:08 +1000 Message-Id: <1468812548-31868-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.5.0.rc3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.169.36.222 Subject: [Qemu-devel] [PATCH qemu] xhci: Fix possible side effect from assert() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" A static analysis tool called BEAM detected possible side effect from assert() calling a helper which may change an XHCI ring after every call. This moves xhci_ring_fetch() out of assert() so it will be called with and without enabled debug. Signed-off-by: Alexey Kardashevskiy --- hw/usb/hcd-xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 976bfb0..188f954 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2201,7 +2201,9 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, xfer->trb_count = length; for (i = 0; i < length; i++) { - assert(xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL)); + TRBType type; + type = xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL); + assert(type); } xfer->streamid = streamid;