All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Erik Rull <erik.rull@rdsoftware.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] USB port NULL pointer causes segv
Date: Wed, 17 Aug 2011 23:43:27 +0200	[thread overview]
Message-ID: <4E4C35FF.2070008@redhat.com> (raw)
In-Reply-To: <4E4BEB50.2080800@rdsoftware.de>

[-- Attachment #1: Type: text/plain, Size: 245 bytes --]

   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


[-- Attachment #2: 0001-usb-linux-constify-port.patch --]
[-- Type: text/plain, Size: 2584 bytes --]

>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(-)

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)
-- 
1.7.1


[-- Attachment #3: 0002-usb-linux-set-port-to-non-NULL-for-proc-bus-usb-devi.patch --]
[-- Type: text/plain, Size: 868 bytes --]

>From 3da0c8ed9d83928bbb88c2ffbd3ae8d2eed2e41a Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 17 Aug 2011 23:36:46 +0200
Subject: [PATCH 2/2] usb-linux: set port to non-NULL for /proc/bus/usb/devices scan

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

diff --git a/usb-linux.c b/usb-linux.c
index dec3bc9..f8a47da 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1505,7 +1505,7 @@ static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
     }
     if (device_count && (vendor_id || product_id)) {
         /* Add the last device.  */
-        ret = func(opaque, bus_num, addr, 0, class_id, vendor_id,
+        ret = func(opaque, bus_num, addr, "?", class_id, vendor_id,
                    product_id, product_name, speed);
     }
  the_end:
-- 
1.7.1


  reply	other threads:[~2011-08-17 21:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17 16:24 [Qemu-devel] USB port NULL pointer causes segv Erik Rull
2011-08-17 21:43 ` Gerd Hoffmann [this message]
2011-08-18 11:50 erik.rull
2011-08-21 15:29 Erik Rull

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=4E4C35FF.2070008@redhat.com \
    --to=kraxel@redhat.com \
    --cc=erik.rull@rdsoftware.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.