Skip to content

Commit d291ffb

Browse files
committed
Merge git://github.com/rustyrussell/linux
* git://github.com/rustyrussell/linux: virtio-pci: fix use after free
2 parents 52e4c2a + 72103bd commit d291ffb

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎drivers/virtio/virtio_pci.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,11 @@ static struct virtio_config_ops virtio_pci_config_ops = {
594594

595595
static void virtio_pci_release_dev(struct device *_d)
596596
{
597-
struct virtio_device *dev = container_of(_d, struct virtio_device,
598-
dev);
599-
struct virtio_pci_device *vp_dev = to_vp_device(dev);
600-
601-
kfree(vp_dev);
597+
/*
598+
* No need for a release method as we allocate/free
599+
* all devices together with the pci devices.
600+
* Provide an empty one to avoid getting a warning from core.
601+
*/
602602
}
603603

604604
/* the PCI probing function */
@@ -686,6 +686,7 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
686686
pci_iounmap(pci_dev, vp_dev->ioaddr);
687687
pci_release_regions(pci_dev);
688688
pci_disable_device(pci_dev);
689+
kfree(vp_dev);
689690
}
690691

691692
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)