PCI host devaddr property fix for 5.2

-----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCAAyFiEEWjIv1avE09usz9GqKAeTb5hNxaYFAl+9IzAUHGVoYWJrb3N0
 QHJlZGhhdC5jb20ACgkQKAeTb5hNxaaqihAAuabU0FZ6Y9Fpt0CvfOrDb7pE2JPg
 JlvuSymXHB6RA/G29UqtszjVfEHvOgr0PsxooXRRbbG9Tr2S/KuiBP+x9qZiesVE
 3Pn5YRcAVz6NpY5ajPCnxqOFnVBGHkEysBi5rsVvhEtXfuDHc4Xc/OL4qDaC2WLP
 Ep8vS4SUlnCpTohchrZYV9GpbItBpTy+G+s/BEWSwixzml06LraE682+HBCQ+LiI
 d0AWSvIKmF/DMceg3ATNOcVkTikfvv7qxTOn0IWfxP+xCjRjMBrsG5SHdxJghFMB
 boFH3R9dIpbLGBRQaPdgzN8tmSU+w6N8ViFyX6a2dv3tGFVIgH4CxmQR/64hxM7w
 3b9nCr51jV03My8HwtqGoPNOm1HjNTXm0RbVn749kxVZdeO56C2uBZB5fp2CakrG
 xpR7rbM9DPk9pFcYB9N8CrpBA6C0CqP61KSPxSKnweSlbnBI2019AjAIWWchqALf
 mhMFGFiXfJMQQipXdI+szxmtzG90CVi0GKhZZixe/S7jT+6JFSokfYqpEMznC7lu
 +d88bJ/kHTQEKRYvD5bE8SSqevHlSASYMR7ZcHZVcWUCmPAxpRba+sM2tebF1Pp5
 iCaOGU3ZzrrBgNTDoNn1u4bnmtkNjiHJja57Rp1pX8ldG2lF8GYohYzkHcyvRbk0
 xK8t0XaQTMwAwS0=
 =pVMm
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-for-5.2-pull-request' into staging

PCI host devaddr property fix for 5.2

# gpg: Signature made Tue 24 Nov 2020 15:13:52 GMT
# gpg:                using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6
# gpg:                issuer "ehabkost@redhat.com"
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full]
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/machine-next-for-5.2-pull-request:
  Revert "hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr()"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-11-24 21:08:29 +00:00
commit 1a6ab01d3f

View File

@ -858,7 +858,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
char *str, *p;
const char *e;
char *e;
unsigned long val;
unsigned long dom = 0, bus = 0;
unsigned int slot = 0, func = 0;
@ -873,23 +873,23 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
}
p = str;
if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xffff || e == p) {
goto inval;
}
if (*e != ':') {
val = strtoul(p, &e, 16);
if (e == p || *e != ':') {
goto inval;
}
bus = val;
p = (char *)e + 1;
if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
p = e + 1;
val = strtoul(p, &e, 16);
if (e == p) {
goto inval;
}
if (*e == ':') {
dom = bus;
bus = val;
p = (char *)e + 1;
if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
p = e + 1;
val = strtoul(p, &e, 16);
if (e == p) {
goto inval;
}
}
@ -898,13 +898,14 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
if (*e != '.') {
goto inval;
}
p = (char *)e + 1;
if (qemu_strtoul(p, &e, 10, &val) < 0 || val > 7 || e == p) {
p = e + 1;
val = strtoul(p, &e, 10);
if (e == p) {
goto inval;
}
func = val;
if (bus > 0xff) {
if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7) {
goto inval;
}