[Pcsclite-cvs-commit] r5852 - /trunk/PCSC/src/hotplug_libusb.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Fri Jul 8 12:04:35 UTC 2011


Author: rousseau
Date: Fri Jul  8 12:04:35 2011
New Revision: 5852

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5852
Log:
HPRescanUsbBus(): check libusb_init() return value

Thanks to Dwi Sasongko Supriyadi for the patch
http://archives.neohapsis.com/archives/dev/muscle/2011-q3/0014.html

Modified:
    trunk/PCSC/src/hotplug_libusb.c

Modified: trunk/PCSC/src/hotplug_libusb.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/hotplug_libusb.c?rev=5852&op=diff
==============================================================================
--- trunk/PCSC/src/hotplug_libusb.c (original)
+++ trunk/PCSC/src/hotplug_libusb.c Fri Jul  8 12:04:35 2011
@@ -32,6 +32,7 @@
 #include <errno.h>
 #include <libusb.h>
 #include <pthread.h>
+#include <signal.h>
 
 #include "misc.h"
 #include "wintypes.h"
@@ -390,9 +391,17 @@
 static void HPEstablishUSBNotifications(int pipefd[2])
 {
 	int i, do_polling;
+	int r;
 	char c = 42;	/* magic value */
 
-	libusb_init(ctx);
+	r = libusb_init(ctx);
+	if (r < 0)
+	{
+		Log2(PCSC_LOG_CRITICAL, "libusb_init failed: %d", r);
+		/* emergency exit */
+		kill(getpid(), SIGTERM);
+		return;
+	}
 
 	/* scan the USB bus for devices at startup */
 	HPRescanUsbBus();




More information about the Pcsclite-cvs-commit mailing list