pci init: fail qemu if devfn exceeding the max devices number supported on bus
A message that is not in the archive (sent off-list or not yet received): 20100824062517.12408.45246.stgit@k1
PATCH 2/3 pci init: fail qemu if devfn exceeding the max devices number supported on bus
assert(devfn < PCIBUS_MAX_DEVICES)
Signed-off-by Ken CC <[email protected]>
--- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci.c +1 -0
@@ -747,6 +747,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,PCIConfigWriteFunc *config_write, bool is_bridge) { + assert(devfn < PCIBUS_MAX_DEVICES);if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) {
broken thread, please ignore.
Quoted 24 lines · Ken CC
assert(devfn < PCIBUS_MAX_DEVICES)Signed-off-by Ken CC <[email protected]>--- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)hw/pci.c +1
-1@@ -747,6 +747,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,PCIConfigWriteFunc *config_write, bool is_bridge) { + assert(devfn < PCIBUS_MAX_DEVICES);if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) { --To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 Check pci slot number in parse_pci_devfn
In reply to a message not in the archiveDefine MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line is bigger than 0x1f, return error -EINVAL.
0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
Signed-off-by Ken CC <[email protected]>
--- hw/qdev-properties.c | 2 ++ hw/qdev.h | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-)
hw/qdev-properties.c +2 -0
@@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)return -EINVAL ; } } +if (slot >MAX_PCI_SLOTS ) +return -EINVAL ;if (str[n] !='\0' )return -EINVAL ;if (fn >7 )
hw/qdev.h +3 -0
@@ -7,6 +7,9 @@#include "qemu-char.h" #include "qemu-option.h" + +#define MAX_PCI_SLOTS 0x1f +typedef struct Property Property ;typedef struct PropertyInfo PropertyInfo ;