[Pcsclite-cvs-commit] r5846 - /trunk/PCSC/src/hotplug_libudev.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Wed Jul 6 19:04:20 UTC 2011


Author: rousseau
Date: Wed Jul  6 19:04:19 2011
New Revision: 5846

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5846
Log:
HPRescanUsbBus(): Move the lock/unlock _around_ the loop so that the
values are constant between check and use.

coverity: Event use: Using an unreliable value of
"readerTracker[i].fullName" inside the second locked section. If the
data that "readerTracker[i].fullName" depends on was changed by another
thread, this use might be incorrect.

Modified:
    trunk/PCSC/src/hotplug_libudev.c

Modified: trunk/PCSC/src/hotplug_libudev.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/hotplug_libudev.c?rev=5846&op=diff
==============================================================================
--- trunk/PCSC/src/hotplug_libudev.c (original)
+++ trunk/PCSC/src/hotplug_libudev.c Wed Jul  6 19:04:19 2011
@@ -497,13 +497,13 @@
 	/* Free the enumerator object */
 	udev_enumerate_unref(enumerate);
 
+	pthread_mutex_lock(&usbNotifierMutex);
 	/* check if all the previously found readers are still present */
 	for (i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
 		if ((READER_ABSENT == readerTracker[i].status)
 			&& (readerTracker[i].fullName != NULL))
 		{
-			pthread_mutex_lock(&usbNotifierMutex);
 
 			Log3(PCSC_LOG_INFO, "Removing USB device[%d]: %s", i,
 				readerTracker[i].devpath);
@@ -517,9 +517,9 @@
 			free(readerTracker[i].fullName);
 			readerTracker[i].fullName = NULL;
 
-			pthread_mutex_unlock(&usbNotifierMutex);
-		}
-	}
+		}
+	}
+	pthread_mutex_unlock(&usbNotifierMutex);
 }
 
 static void HPEstablishUSBNotifications(struct udev *udev)




More information about the Pcsclite-cvs-commit mailing list