From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Geoffrey McRae" <geoff@hostfission.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Klaus Herman" <kherman@inbox.lv>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH for-5.2] Revert "hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr()"
Date: Fri, 20 Nov 2020 08:04:54 -0500 [thread overview]
Message-ID: <20201120130409.956956-1-mst@redhat.com> (raw)
This reverts commit bccb20c49df1bd683248a366021973901c11982f as it
introduced a regression blocking bus addresses > 0x1f or higher.
Legal bus numbers go up to 0xff.
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Fixes: bccb20c49df ("Use qemu_strtoul() in set_pci_host_devaddr()")
Reported-by: Klaus Herman <kherman@inbox.lv>
Reported-by: Geoffrey McRae <geoff@hostfission.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
checkpatch will complain since it does not like strtoul but
we had it for years so should be ok for 5.2, right?
hw/core/qdev-properties-system.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index b81a4e8d14..9d80a07d26 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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;
}
--
MST
next reply other threads:[~2020-11-20 13:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 13:04 Michael S. Tsirkin [this message]
2020-11-20 13:09 ` [PATCH for-5.2] Revert "hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr()" no-reply
2020-11-20 13:10 ` Paolo Bonzini
2020-11-24 14:13 ` Philippe Mathieu-Daudé
2020-11-24 15:06 ` Eduardo Habkost
2020-11-24 15:49 ` Philippe Mathieu-Daudé
2020-11-20 13:49 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120130409.956956-1-mst@redhat.com \
--to=mst@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=geoff@hostfission.com \
--cc=kherman@inbox.lv \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).