yeahuh / rpms / qemu-kvm

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