sjur.brandeland at stericsson.com
2012-Sep-03 13:50 UTC
[PATCH] virtio: Don't access device data after unregistration.
From: Sjur Br?ndeland <sjur.brandeland at stericsson.com> Fix panic in virtio.c when CONFIG_DEBUG_SLAB is set. Use device_del() and put_device() instead of device_unregister(), and access device data before calling put_device(). Signed-off-by: Sjur Br?ndeland <sjur.brandeland at stericsson.com> cc: Guzman Lugo, Fernadndo <fernando.lugo at ti.com> cc: Michael S. Tsirkin <mst at redhat.com> cc: virtualization at lists.linux-foundation.org cc: Ohad Ben-Cohen <ohad at wizery.com> --- drivers/virtio/virtio.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index c3b3f7f..71eacd1 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -225,8 +225,9 @@ EXPORT_SYMBOL_GPL(register_virtio_device); void unregister_virtio_device(struct virtio_device *dev) { - device_unregister(&dev->dev); + device_del(&dev->dev); ida_simple_remove(&virtio_index_ida, dev->index); + put_device(&dev->dev); } EXPORT_SYMBOL_GPL(unregister_virtio_device); -- 1.7.5.4
Michael S. Tsirkin
2012-Sep-03 14:14 UTC
[PATCH] virtio: Don't access device data after unregistration.
On Mon, Sep 03, 2012 at 03:50:42PM +0200, sjur.brandeland at stericsson.com wrote:> From: Sjur Br?ndeland <sjur.brandeland at stericsson.com> > > Fix panic in virtio.c when CONFIG_DEBUG_SLAB is set.What's the root cause of the panic?> Use device_del() and put_device() instead of > device_unregister(), and access device data before > calling put_device().Why does this help? Does device_unregister free the device so dev->index access crashes? If yes virtio_pci_remove will crash too as it accesses the device after the call to unregister_virtio_device so the fix won't be effective.> Signed-off-by: Sjur Br?ndeland <sjur.brandeland at stericsson.com> > cc: Guzman Lugo, Fernadndo <fernando.lugo at ti.com> > cc: Michael S. Tsirkin <mst at redhat.com> > cc: virtualization at lists.linux-foundation.org > cc: Ohad Ben-Cohen <ohad at wizery.com> > --- > drivers/virtio/virtio.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c > index c3b3f7f..71eacd1 100644 > --- a/drivers/virtio/virtio.c > +++ b/drivers/virtio/virtio.c > @@ -225,8 +225,9 @@ EXPORT_SYMBOL_GPL(register_virtio_device); > > void unregister_virtio_device(struct virtio_device *dev) > { > - device_unregister(&dev->dev); > + device_del(&dev->dev); > ida_simple_remove(&virtio_index_ida, dev->index); > + put_device(&dev->dev); > } > EXPORT_SYMBOL_GPL(unregister_virtio_device); > > -- > 1.7.5.4
Maybe Matching Threads
- [PATCH] virtio: Don't access device data after unregistration.
- [RFCv2 1/2] virtio_console: Add support for DMA memory allocation
- [RFCv2 1/2] virtio_console: Add support for DMA memory allocation
- [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"
- [PATCH] Revert "virtio_console: Initialize guest_connected=true for rproc_serial"