Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio-pci: do not oops on config change if driver not loaded

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>

authored by

Mark McLoughlin and committed by
Linus Torvalds
3fff0179 720eba31

+1 -1
+1 -1
drivers/virtio/virtio_pci.c
··· 192 192 drv = container_of(vp_dev->vdev.dev.driver, 193 193 struct virtio_driver, driver); 194 194 195 - if (drv->config_changed) 195 + if (drv && drv->config_changed) 196 196 drv->config_changed(&vp_dev->vdev); 197 197 } 198 198