summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-05-25 09:23:21 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-12 13:05:51 -0700
commitfc2b9edc19565ff5f5a7b113756e99f5b31a77d1 (patch)
tree17bf617ec2278b996c8bdefe8e60e19ae93f1c66
parent151977d1fed19efca4435f9485a826e4671846ce (diff)
downloadusbutils-fc2b9edc19565ff5f5a7b113756e99f5b31a77d1.tar.gz
Fix lsusb double-free
Am 25.05.2011 00:18 schrieb Greg KH: > On Wed, May 25, 2011 at 12:02:48AM +0200, Carl-Daniel Hailfinger wrote: > >> I was playing with the "authorized" attribute of USB devices in >> sysfs. >> If at least one device has authorized=0, >> "lsusb" will print nothing (not even the host controllers) >> > Well, if the device can't be accessed, as you disabled it through the > authorised=0 setting, lsusb shouldn't really be able to do much with it. > Turns out there are two bugs: libusb screws up walking the bus and claims there are -1 devices (error). lsusb ignores that and tries to free a nonexisting object. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--lsusb.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lsusb.c b/lsusb.c
index dba88e2..3364493 100644
--- a/lsusb.c
+++ b/lsusb.c
@@ -3848,6 +3848,8 @@ static int list_devices(libusb_context *ctx, int busnum, int devnum, int vendori
status = 1; /* 1 device not found, 0 device found */
num_devs = libusb_get_device_list(ctx, &list);
+ if (num_devs < 0)
+ goto error;
for (i = 0; i < num_devs; ++i) {
libusb_device *dev = list[i];
@@ -3877,6 +3879,7 @@ static int list_devices(libusb_context *ctx, int busnum, int devnum, int vendori
}
libusb_free_device_list(list, 0);
+error:
return status;
}