Patchwork USB port NULL pointer causes segv

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 17, 2011, 9:43 p.m.
Message ID <4E4C35FF.2070008@redhat.com>
Download mbox | patch
Permalink /patch/110372/
State New
Headers show

Comments

Gerd Hoffmann - Aug. 17, 2011, 9:43 p.m.
Hi,

> in usb-linux.c my qemu crashes in
> static int usb_host_open(USBHostDevice *dev, int bus_num, int addr, char
> *port, const char *prod_name, int speed)
>
> because port is NULL.

The attached patches should fix this.

cheers,
   Gerd
From 15fd107f500f8a0f6ffa05fa3a9775d37afda1bd Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 17 Aug 2011 23:35:45 +0200
Subject: [PATCH 1/2] usb-linux: constify port

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 usb-linux.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

Patch

diff --git a/usb-linux.c b/usb-linux.c
index 5562187..dec3bc9 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -53,7 +53,7 @@  struct usb_ctrltransfer {
     void *data;
 };
 
-typedef int USBScanFunc(void *opaque, int bus_num, int addr, char *port,
+typedef int USBScanFunc(void *opaque, int bus_num, int addr, const char *port,
                         int class_id, int vendor_id, int product_id,
                         const char *product_name, int speed);
 
@@ -1135,7 +1135,8 @@  static int usb_linux_full_speed_compat(USBHostDevice *dev)
 }
 
 static int usb_host_open(USBHostDevice *dev, int bus_num,
-                        int addr, char *port, const char *prod_name, int speed)
+                         int addr, const char *port,
+                         const char *prod_name, int speed)
 {
     int fd = -1, ret;
     char buf[1024];
@@ -1713,7 +1714,8 @@  static int usb_host_scan(void *opaque, USBScanFunc *func)
 
 static QEMUTimer *usb_auto_timer;
 
-static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port,
+static int usb_host_auto_scan(void *opaque, int bus_num,
+                              int addr, const char *port,
                               int class_id, int vendor_id, int product_id,
                               const char *product_name, int speed)
 {
@@ -1875,7 +1877,8 @@  static const char *usb_class_str(uint8_t class)
     return p->class_name;
 }
 
-static void usb_info_device(Monitor *mon, int bus_num, int addr, char *port,
+static void usb_info_device(Monitor *mon, int bus_num,
+                            int addr, const char *port,
                             int class_id, int vendor_id, int product_id,
                             const char *product_name,
                             int speed)
@@ -1916,7 +1919,7 @@  static void usb_info_device(Monitor *mon, int bus_num, int addr, char *port,
 }
 
 static int usb_host_info_device(void *opaque, int bus_num, int addr,
-                                char *path, int class_id,
+                                const char *path, int class_id,
                                 int vendor_id, int product_id,
                                 const char *product_name,
                                 int speed)