From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N4qPG-0003cS-Ck for qemu-devel@nongnu.org; Mon, 02 Nov 2009 01:28:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N4qPB-0003Yp-3O for qemu-devel@nongnu.org; Mon, 02 Nov 2009 01:28:45 -0500 Received: from [199.232.76.173] (port=59714 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4qPA-0003YX-P1 for qemu-devel@nongnu.org; Mon, 02 Nov 2009 01:28:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14560) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N4qPA-0004IS-7S for qemu-devel@nongnu.org; Mon, 02 Nov 2009 01:28:40 -0500 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.13.8/8.13.8) with ESMTP id nA26SckI022720 for ; Mon, 2 Nov 2009 01:28:38 -0500 From: Amit Shah Date: Mon, 2 Nov 2009 11:57:56 +0530 Message-Id: <1257143276-9428-1-git-send-email-amit.shah@redhat.com> Subject: [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Amit Shah A bus may have hotplugging enabled but not have the 'unplug' callback defined, which would lead to a crash on trying to unplug a device on the bus. Fix by checking if the callback is valid Signed-off-by: Amit Shah --- hw/qdev.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 374d2d0..1a9eb2e 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -258,6 +258,11 @@ int qdev_unplug(DeviceState *dev) dev->parent_bus->name); return -1; } + if (!dev->info->unplug) { + qemu_error("Unplug event for bus %s not defined\n", + dev->parent_bus->name); + return -1; + } return dev->info->unplug(dev); } -- 1.6.2.5