virtio-pci: do not oops on config change if driver not loaded
authorMark McLoughlin <markmc@redhat.com>
Tue, 3 Feb 2009 03:03:53 +0000 (13:33 +1030)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 3 Feb 2009 03:17:56 +0000 (19:17 -0800)
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/virtio/virtio_pci.c

index bef6b45e8a5ce4baaa0e1373338d5f02e879bbb0..330aacbdec1f7b48fd2774f19e5788461463f07a 100644 (file)
@@ -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);
        }