aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>2014-08-04 18:17:23 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2014-10-23 11:24:02 -0400
commit486edb24952c930966dad125f6727017353e9361 (patch)
tree985f0c343a3211f0676973f08b330ede2fda4500 /drivers/xen
parent1ea644c8f93f3435760d8b88c25d56475d8b7778 (diff)
xen/pci: Allocate memory for physdev_pci_device_add's optarr
physdev_pci_device_add's optarr[] is a zero-sized array and therefore reference to add.optarr[0] is accessing memory that does not belong to the 'add' variable. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/pci.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c
index dd9c249ea311..95ee4302ffb8 100644
--- a/drivers/xen/pci.c
+++ b/drivers/xen/pci.c
@@ -41,24 +41,29 @@ static int xen_add_device(struct device *dev)
41#endif 41#endif
42 42
43 if (pci_seg_supported) { 43 if (pci_seg_supported) {
44 struct physdev_pci_device_add add = { 44 struct {
45 .seg = pci_domain_nr(pci_dev->bus), 45 struct physdev_pci_device_add add;
46 .bus = pci_dev->bus->number, 46 uint32_t pxm;
47 .devfn = pci_dev->devfn 47 } add_ext = {
48 .add.seg = pci_domain_nr(pci_dev->bus),
49 .add.bus = pci_dev->bus->number,
50 .add.devfn = pci_dev->devfn
48 }; 51 };
52 struct physdev_pci_device_add *add = &add_ext.add;
53
49#ifdef CONFIG_ACPI 54#ifdef CONFIG_ACPI
50 acpi_handle handle; 55 acpi_handle handle;
51#endif 56#endif
52 57
53#ifdef CONFIG_PCI_IOV 58#ifdef CONFIG_PCI_IOV
54 if (pci_dev->is_virtfn) { 59 if (pci_dev->is_virtfn) {
55 add.flags = XEN_PCI_DEV_VIRTFN; 60 add->flags = XEN_PCI_DEV_VIRTFN;
56 add.physfn.bus = physfn->bus->number; 61 add->physfn.bus = physfn->bus->number;
57 add.physfn.devfn = physfn->devfn; 62 add->physfn.devfn = physfn->devfn;
58 } else 63 } else
59#endif 64#endif
60 if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) 65 if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn))
61 add.flags = XEN_PCI_DEV_EXTFN; 66 add->flags = XEN_PCI_DEV_EXTFN;
62 67
63#ifdef CONFIG_ACPI 68#ifdef CONFIG_ACPI
64 handle = ACPI_HANDLE(&pci_dev->dev); 69 handle = ACPI_HANDLE(&pci_dev->dev);
@@ -77,8 +82,8 @@ static int xen_add_device(struct device *dev)
77 status = acpi_evaluate_integer(handle, "_PXM", 82 status = acpi_evaluate_integer(handle, "_PXM",
78 NULL, &pxm); 83 NULL, &pxm);
79 if (ACPI_SUCCESS(status)) { 84 if (ACPI_SUCCESS(status)) {
80 add.optarr[0] = pxm; 85 add->optarr[0] = pxm;
81 add.flags |= XEN_PCI_DEV_PXM; 86 add->flags |= XEN_PCI_DEV_PXM;
82 break; 87 break;
83 } 88 }
84 status = acpi_get_parent(handle, &handle); 89 status = acpi_get_parent(handle, &handle);
@@ -86,7 +91,7 @@ static int xen_add_device(struct device *dev)
86 } 91 }
87#endif /* CONFIG_ACPI */ 92#endif /* CONFIG_ACPI */
88 93
89 r = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add); 94 r = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, add);
90 if (r != -ENOSYS) 95 if (r != -ENOSYS)
91 return r; 96 return r;
92 pci_seg_supported = false; 97 pci_seg_supported = false;