Patchwork [STABLE,2/3] Avoid crash on '-usbdevice <device>' without parameters

login
register
mail settings
Submitter Luiz Capitulino
Date June 2, 2010, 8:19 p.m.
Message ID <1275509996-25823-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/54427/
State New
Headers show

Comments

Luiz Capitulino - June 2, 2010, 8:19 p.m.
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(-)

Patch

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);
     }