summaryrefslogtreecommitdiff
path: root/extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch
diff options
context:
space:
mode:
Diffstat (limited to 'extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch')
-rw-r--r--extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch b/extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch
new file mode 100644
index 000000000..711dab8ce
--- /dev/null
+++ b/extra/cups/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch
@@ -0,0 +1,54 @@
+Description: Add more error handling to the libusb-based USB backend,
+ especially to avoid a crash when USB is disabled in the BIOS. Also
+ discard that error when counting warning messages.
+Author: Till Kamppeter <till.kamppeter@gmail.com>
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1108719
+Last-Update: 2013-05-03
+--- a/backend/usb-libusb.c
++++ b/backend/usb-libusb.c
+@@ -898,7 +898,8 @@
+ /* Pointer to current alternate setting */
+ const struct libusb_endpoint_descriptor *endpptr = NULL;
+ /* Pointer to current endpoint */
+- ssize_t numdevs, /* number of connected devices */
++ ssize_t err = 0,
++ numdevs, /* number of connected devices */
+ i = 0;
+ uint8_t conf, /* Current configuration */
+ iface, /* Current interface */
+@@ -917,7 +918,13 @@
+ * Initialize libusb...
+ */
+
+- libusb_init(NULL);
++ err = libusb_init(NULL);
++ if (err)
++ {
++ fprintf(stderr, "WARNING: Unable to initialize USB access via libusb, libusb error %i\n", err);
++ return (NULL);
++ }
++
+ numdevs = libusb_get_device_list(NULL, &list);
+ fprintf(stderr, "DEBUG: libusb_get_device_list=%d\n", (int)numdevs);
+
+@@ -1087,7 +1094,8 @@
+ * Clean up ....
+ */
+
+- libusb_free_device_list(list, 1);
++ if (numdevs >= 0)
++ libusb_free_device_list(list, 1);
+ libusb_exit(NULL);
+
+ return (NULL);
+--- a/test/run-stp-tests.sh
++++ b/test/run-stp-tests.sh
+@@ -838,7 +838,7 @@
+ fi
+
+ # Warning log messages
+-count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
++count=`$GREP '^W ' /tmp/cups-$user/log/error_log | grep -v 'Unable to initialize USB access via libusb, libusb error' | wc -l | awk '{print $1}'`
+ if test $count != 9; then
+ echo "FAIL: $count warning messages, expected 9."
+ $GREP '^W ' /tmp/cups-$user/log/error_log