From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Hans de Goede 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> Subject: [Qemu-devel] [PATCH 07/11] usb: assert on calling usb_attach(port, NULL) on a port without a dev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Hans de Goede , qemu-devel@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; } } -- 1.7.5.1