From patchwork Fri Jun 24 19:32:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 101884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2739DB6F84 for ; Sat, 25 Jun 2011 05:58:58 +1000 (EST) Received: from localhost ([::1]:42870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QaCWk-0007zj-VW for incoming@patchwork.ozlabs.org; Fri, 24 Jun 2011 15:58:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:42929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QaC70-0001By-Os for qemu-devel@nongnu.org; Fri, 24 Jun 2011 15:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QaC6y-0002PS-Tp for qemu-devel@nongnu.org; Fri, 24 Jun 2011 15:32:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QaC6y-0002P3-Eb for qemu-devel@nongnu.org; Fri, 24 Jun 2011 15:32:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5OJWFg2001270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Jun 2011 15:32:15 -0400 Received: from shalem.localdomain.com (vpn1-4-129.ams2.redhat.com [10.36.4.129]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5OJW4ua031987; Fri, 24 Jun 2011 15:32:14 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Fri, 24 Jun 2011 21:32:54 +0200 Message-Id: <1308943978-6152-8-git-send-email-hdegoede@redhat.com> In-Reply-To: <1308943978-6152-1-git-send-email-hdegoede@redhat.com> References: <1308943978-6152-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 07/11] usb: assert on calling usb_attach(port, NULL) on a port without a dev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org with the "usb-ehci: cleanup port reset handling" patch in place no callers are calling usb_attach(port, NULL) for a port where port->dev is NULL. Doing that makes no sense as that causes the port detach op to get called for a port with nothing attached. Add an assert that port->dev != NULL when dev == NULL, and remove the check for not having a port->dev in the dev == NULL case. Signed-off-by: Hans de Goede --- hw/usb.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb.c b/hw/usb.c index 735ffd1..27a983c 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -40,12 +40,11 @@ void usb_attach(USBPort *port, USBDevice *dev) } else { /* detach */ dev = port->dev; + assert(dev); port->ops->detach(port); - if (dev) { - usb_send_msg(dev, USB_MSG_DETACH); - dev->port = NULL; - port->dev = NULL; - } + usb_send_msg(dev, USB_MSG_DETACH); + dev->port = NULL; + port->dev = NULL; } }