From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N4tCD-0003xx-5I for qemu-devel@nongnu.org; Mon, 02 Nov 2009 04:27:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N4tC8-0003tI-Bj for qemu-devel@nongnu.org; Mon, 02 Nov 2009 04:27:28 -0500 Received: from [199.232.76.173] (port=47165 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4tC8-0003tD-4F for qemu-devel@nongnu.org; Mon, 02 Nov 2009 04:27:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49249) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N4tC7-0004dH-Ll for qemu-devel@nongnu.org; Mon, 02 Nov 2009 04:27:23 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA29RMGp022440 for ; Mon, 2 Nov 2009 04:27:23 -0500 From: Amit Shah Date: Mon, 2 Nov 2009 14:56:41 +0530 Message-Id: <1257154001-15403-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 introducing an assert to check if the callback is valid. Signed-off-by: Amit Shah --- hw/qdev.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index c7884d0..d19d531 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -258,6 +258,8 @@ int qdev_unplug(DeviceState *dev) dev->parent_bus->name); return -1; } + assert(dev->info->unplug != NULL); + return dev->info->unplug(dev); } -- 1.6.2.5