linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio-pci: do not oops on config change if driver not loaded
@ 2009-01-29 15:32 Mark McLoughlin
  2009-01-30  1:45 ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Mark McLoughlin @ 2009-01-29 15:32 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel, qemu-devel, Mark McLoughlin

The host really shouldn't be notifying us of config changes
before the device status is VIRTIO_CONFIG_S_DRIVER or
VIRTIO_CONFIG_S_DRIVER_OK.

However, if we do happen to be interrupted while we're not
attached to a driver, we really shouldn't oops. Prevent
this simply by checking that device->driver is non-NULL
before trying to notify the driver of config changes.

Problem observed by doing a "set_link virtio.0 down" with
QEMU before the net driver had been loaded.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 drivers/virtio/virtio_pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index bef6b45..330aacb 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -192,7 +192,7 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)
 		drv = container_of(vp_dev->vdev.dev.driver,
 				   struct virtio_driver, driver);
 
-		if (drv->config_changed)
+		if (drv && drv->config_changed)
 			drv->config_changed(&vp_dev->vdev);
 	}
 
-- 
1.6.0.6


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

* Re: [PATCH] virtio-pci: do not oops on config change if driver not loaded
  2009-01-29 15:32 [PATCH] virtio-pci: do not oops on config change if driver not loaded Mark McLoughlin
@ 2009-01-30  1:45 ` Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2009-01-30  1:45 UTC (permalink / raw)
  To: Mark McLoughlin; +Cc: linux-kernel, qemu-devel

On Friday 30 January 2009 02:02:16 Mark McLoughlin wrote:
> The host really shouldn't be notifying us of config changes
> before the device status is VIRTIO_CONFIG_S_DRIVER or
> VIRTIO_CONFIG_S_DRIVER_OK.
> 
> However, if we do happen to be interrupted while we're not
> attached to a driver, we really shouldn't oops.

Thanks, applied!

Rusty.

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

* [PATCH] virtio-pci: do not oops on config change if driver not loaded
@ 2009-02-03  3:03 Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2009-02-03  3:03 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Mark McLoughlin

From: Mark McLoughlin <markmc@redhat.com>

The host really shouldn't be notifying us of config changes
before the device status is VIRTIO_CONFIG_S_DRIVER or
VIRTIO_CONFIG_S_DRIVER_OK.

However, if we do happen to be interrupted while we're not
attached to a driver, we really shouldn't oops. Prevent
this simply by checking that device->driver is non-NULL
before trying to notify the driver of config changes.

Problem observed by doing a "set_link virtio.0 down" with
QEMU before the net driver had been loaded.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/virtio/virtio_pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index bef6b45..330aacb 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -192,7 +192,7 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)
 		drv = container_of(vp_dev->vdev.dev.driver,
 				   struct virtio_driver, driver);
 
-		if (drv->config_changed)
+		if (drv && drv->config_changed)
 			drv->config_changed(&vp_dev->vdev);
 	}
 

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

end of thread, other threads:[~2009-02-03  3:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-29 15:32 [PATCH] virtio-pci: do not oops on config change if driver not loaded Mark McLoughlin
2009-01-30  1:45 ` Rusty Russell
2009-02-03  3:03 Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).