From patchwork Fri May 3 13:25:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 241312 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6C5012C00D7 for ; Fri, 3 May 2013 23:26:10 +1000 (EST) Received: from localhost ([::1]:53994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYG00-0001L2-1z for incoming@patchwork.ozlabs.org; Fri, 03 May 2013 09:26:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYFzd-0001JU-HX for qemu-devel@nongnu.org; Fri, 03 May 2013 09:25:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYFzY-0007AQ-Rr for qemu-devel@nongnu.org; Fri, 03 May 2013 09:25:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYFzY-0007AK-KP; Fri, 03 May 2013 09:25:40 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r43DPdnH014887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 May 2013 09:25:39 -0400 Received: from thinkpad.redhat.com (vpn-224-36.phx2.redhat.com [10.3.224.36]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r43DPbNR013099; Fri, 3 May 2013 09:25:38 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 3 May 2013 15:25:36 +0200 Message-Id: <1367587536-14964-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, bonzini@gnu.org, afaerber@suse.de Subject: [Qemu-devel] [PATCH for-1.5] qdev: skip bus check for bus-less devices in qdev_unplug() 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 Since commit 2f7bd829db "qdev: Fix device_add bus assumptions" it's possible to device_add bus-less device, but if such device is unplugged it will dereference NULL parent_bus in qdev_unplug(). Fix it by taking in account that parent_bus might be NULL and skipping bus check. Signed-off-by: Igor Mammedov --- hw/core/qdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index ab1d8f5..069ac90 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -208,7 +208,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) { DeviceClass *dc = DEVICE_GET_CLASS(dev); - if (!dev->parent_bus->allow_hotplug) { + if (dev->parent_bus && !dev->parent_bus->allow_hotplug) { error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); return; }