All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it
@ 2009-11-02  9:26 Amit Shah
  2009-11-02  9:58 ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2009-11-02  9:26 UTC (permalink / raw)
  To: qemu-devel; +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 <amit.shah@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it
  2009-11-02  9:26 [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it Amit Shah
@ 2009-11-02  9:58 ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-11-02  9:58 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-devel

On 11/02/09 10:26, Amit Shah wrote:
> 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<amit.shah@redhat.com>

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it
  2009-11-02  6:27 Amit Shah
@ 2009-11-02  9:18 ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-11-02  9:18 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-devel

On 11/02/09 07:27, Amit Shah wrote:
> 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.

Which would be a clear bug in the bus implementation.

> +    if (!dev->info->unplug) {

assert(dev->info->unplug != NULL) ?

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it
@ 2009-11-02  6:27 Amit Shah
  2009-11-02  9:18 ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2009-11-02  6:27 UTC (permalink / raw)
  To: qemu-devel; +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 <amit.shah@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-02  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-02  9:26 [Qemu-devel] [PATCH] qdev: Check if unplug handler exists before calling it Amit Shah
2009-11-02  9:58 ` Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2009-11-02  6:27 Amit Shah
2009-11-02  9:18 ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.