* [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash
@ 2010-06-02 20:19 Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 1/3] " Luiz Capitulino
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 20:19 UTC (permalink / raw)
To: qemu-devel
This series fixes bug 573827, which is a segfault when you do:
$ qemu -usbdevice serial
All commits backported from current master, just minimally tested.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [STABLE 1/3] Fix -usbdevice crash
2010-06-02 20:19 [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Luiz Capitulino
@ 2010-06-02 20:19 ` Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 2/3] Avoid crash on '-usbdevice <device>' without parameters Luiz Capitulino
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 20:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
From: Paul Brook <paul@codesourcery.com>
If -usbdevice is used on a machine with no USB busses, usb_create
will fail and return NULL. Patch below handles this failure gracefully
rather than crashing when we try to init the device.
Signed-off-by: Paul Brook <paul@codesourcery.com>
(cherry picked from commit d44168fffa07fc57e61a37da65e9348661dec887)
---
hw/usb-bus.c | 3 +++
hw/usb-msd.c | 3 +++
hw/usb-net.c | 3 +++
hw/usb-serial.c | 3 +++
4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 54027df..7c82314 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -102,6 +102,9 @@ USBDevice *usb_create(USBBus *bus, const char *name)
USBDevice *usb_create_simple(USBBus *bus, const char *name)
{
USBDevice *dev = usb_create(bus, name);
+ if (!dev) {
+ hw_error("Failed to create USB device '%s'\n", name);
+ }
qdev_init_nofail(&dev->qdev);
return dev;
}
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 1fb62ad..9d8d044 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -592,6 +592,9 @@ static USBDevice *usb_msd_init(const char *filename)
/* create guest device */
dev = usb_create(NULL /* FIXME */, "usb-storage");
+ if (!dev) {
+ return NULL;
+ }
qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
if (qdev_init(&dev->qdev) < 0)
return NULL;
diff --git a/hw/usb-net.c b/hw/usb-net.c
index cfd2f62..6875f11 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1491,6 +1491,9 @@ static USBDevice *usb_net_init(const char *cmdline)
}
dev = usb_create(NULL /* FIXME */, "usb-net");
+ if (!dev) {
+ return NULL;
+ }
qdev_set_nic_properties(&dev->qdev, &nd_table[idx]);
qdev_init_nofail(&dev->qdev);
return dev;
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index c3f3401..1410b11 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -594,6 +594,9 @@ static USBDevice *usb_serial_init(const char *filename)
return NULL;
dev = usb_create(NULL /* FIXME */, "usb-serial");
+ if (!dev) {
+ return NULL;
+ }
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [STABLE 2/3] Avoid crash on '-usbdevice <device>' without parameters
2010-06-02 20:19 [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 1/3] " Luiz Capitulino
@ 2010-06-02 20:19 ` Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 3/3] usb-bus: fix no params Luiz Capitulino
2010-06-09 11:03 ` [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Aurelien Jarno
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 20:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Jan Kiszka
From: Jan Kiszka <jan.kiszka@web.de>
Many usbdevice_init implementors assume params is non-NULL.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 702f3e0fb52c124c07f215426eeadb70a716643f)
---
hw/usb-bus.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 7c82314..3bb8986 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -264,7 +264,8 @@ USBDevice *usbdevice_create(const char *cmdline)
USBBus *bus = usb_bus_find(-1 /* any */);
DeviceInfo *info;
USBDeviceInfo *usb;
- char driver[32], *params;
+ char driver[32];
+ const char *params;
int len;
params = strchr(cmdline,':');
@@ -275,6 +276,7 @@ USBDevice *usbdevice_create(const char *cmdline)
len = sizeof(driver);
pstrcpy(driver, len, cmdline);
} else {
+ params = "";
pstrcpy(driver, sizeof(driver), cmdline);
}
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [STABLE 3/3] usb-bus: fix no params
2010-06-02 20:19 [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 1/3] " Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 2/3] Avoid crash on '-usbdevice <device>' without parameters Luiz Capitulino
@ 2010-06-02 20:19 ` Luiz Capitulino
2010-06-09 11:03 ` [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Aurelien Jarno
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 20:19 UTC (permalink / raw)
To: qemu-devel; +Cc: TeLeMan, Aurelien Jarno
After commit 702f3e0fb52c124c07f215426eeadb70a716643f, the params is
nerver NULL. It should check *params instead of params to determine
whether the params is empty.
Conflicts:
hw/usb-bus.c
Signed-off-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 98f22dc172e1ebd5341da3de0d67666442566f72)
---
hw/usb-bus.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 3bb8986..aae1fef 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -299,7 +299,7 @@ USBDevice *usbdevice_create(const char *cmdline)
}
if (!usb->usbdevice_init) {
- if (params) {
+ if (*params) {
qemu_error("usbdevice %s accepts no params\n", driver);
return NULL;
}
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash
2010-06-02 20:19 [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Luiz Capitulino
` (2 preceding siblings ...)
2010-06-02 20:19 ` [Qemu-devel] [STABLE 3/3] usb-bus: fix no params Luiz Capitulino
@ 2010-06-09 11:03 ` Aurelien Jarno
3 siblings, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2010-06-09 11:03 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
On Wed, Jun 02, 2010 at 05:19:53PM -0300, Luiz Capitulino wrote:
> This series fixes bug 573827, which is a segfault when you do:
>
> $ qemu -usbdevice serial
>
> All commits backported from current master, just minimally tested.
>
Thanks, applied.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-09 11:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 20:19 [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 1/3] " Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 2/3] Avoid crash on '-usbdevice <device>' without parameters Luiz Capitulino
2010-06-02 20:19 ` [Qemu-devel] [STABLE 3/3] usb-bus: fix no params Luiz Capitulino
2010-06-09 11:03 ` [Qemu-devel] [STABLE 0/3] Fix -usbdevice crash Aurelien Jarno
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).