|
|
9ae3a8 |
From 7940a4b551e845a34409ad79a6250c5ea2f97df6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 11 Jul 2014 14:21:10 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 30/43] usb: initialize libusb_device to avoid crash
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1405088470-24115-38-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 59842
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 37/37] usb: initialize libusb_device to avoid crash
|
|
|
9ae3a8 |
Bugzilla: 1111450
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Jincheng Miao <jmiao@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
If libusb_get_device_list() fails, the uninitialized local variable
|
|
|
9ae3a8 |
libusb_device would be passed to libusb_free_device_list(), that
|
|
|
9ae3a8 |
will cause a crash, like:
|
|
|
9ae3a8 |
(gdb) bt
|
|
|
9ae3a8 |
#0 0x00007fbbb4bafc10 in pthread_mutex_lock () from /lib64/libpthread.so.0
|
|
|
9ae3a8 |
#1 0x00007fbbb233e653 in libusb_unref_device (dev=0x6275682d627375)
|
|
|
9ae3a8 |
at core.c:902
|
|
|
9ae3a8 |
#2 0x00007fbbb233e739 in libusb_free_device_list (list=0x7fbbb6e8436e,
|
|
|
9ae3a8 |
unref_devices=<optimized out>) at core.c:653
|
|
|
9ae3a8 |
#3 0x00007fbbb6cd80a4 in usb_host_auto_check (unused=unused@entry=0x0)
|
|
|
9ae3a8 |
at hw/usb/host-libusb.c:1446
|
|
|
9ae3a8 |
#4 0x00007fbbb6cd8525 in usb_host_initfn (udev=0x7fbbbd3c5670)
|
|
|
9ae3a8 |
at hw/usb/host-libusb.c:912
|
|
|
9ae3a8 |
#5 0x00007fbbb6cc123b in usb_device_init (dev=0x7fbbbd3c5670)
|
|
|
9ae3a8 |
at hw/usb/bus.c:106
|
|
|
9ae3a8 |
...
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
So initialize libusb_device at the begin time.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Jincheng Miao <jmiao@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 3ce21445387c64032a21ae73c995195307a28a36)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/host-libusb.c | 4 ++--
|
|
|
9ae3a8 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/host-libusb.c | 4 ++--
|
|
|
9ae3a8 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
|
|
|
9ae3a8 |
index 8510902..ef3dd5f 100644
|
|
|
9ae3a8 |
--- a/hw/usb/host-libusb.c
|
|
|
9ae3a8 |
+++ b/hw/usb/host-libusb.c
|
|
|
9ae3a8 |
@@ -1384,7 +1384,7 @@ static void usb_host_auto_check(void *unused)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
struct USBHostDevice *s;
|
|
|
9ae3a8 |
struct USBAutoFilter *f;
|
|
|
9ae3a8 |
- libusb_device **devs;
|
|
|
9ae3a8 |
+ libusb_device **devs = NULL;
|
|
|
9ae3a8 |
struct libusb_device_descriptor ddesc;
|
|
|
9ae3a8 |
int unconnected = 0;
|
|
|
9ae3a8 |
int i, n;
|
|
|
9ae3a8 |
@@ -1485,7 +1485,7 @@ static void usb_host_auto_check(void *unused)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void usb_host_info(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- libusb_device **devs;
|
|
|
9ae3a8 |
+ libusb_device **devs = NULL;
|
|
|
9ae3a8 |
struct libusb_device_descriptor ddesc;
|
|
|
9ae3a8 |
char port[16];
|
|
|
9ae3a8 |
int i, n;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|