[gnome-settings-daemon] smartcard: fix lock confusion in gsd_smartcard_manager_get_login_token



commit e1aac8dd479202ce0f697de22a47777ea195cb3e
Author: Ray Strode <rstrode redhat com>
Date:   Mon Oct 20 19:15:15 2014 -0400

    smartcard: fix lock confusion in gsd_smartcard_manager_get_login_token
    
    gsd_smartcard_manager_get_login_token will return as soon as it finds
    a login token. In doing so, it neglects to drop the lock it took before
    its search began.
    
    This commit drops the early return from the code so that the found
    and not found cases follow the same exit path, where the lock is
    properly dropped.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738906

 plugins/smartcard/gsd-smartcard-manager.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/plugins/smartcard/gsd-smartcard-manager.c b/plugins/smartcard/gsd-smartcard-manager.c
index 6c3c1cb..e81ace2 100644
--- a/plugins/smartcard/gsd-smartcard-manager.c
+++ b/plugins/smartcard/gsd-smartcard-manager.c
@@ -852,26 +852,25 @@ PK11SlotInfo *
 gsd_smartcard_manager_get_login_token (GsdSmartcardManager *self)
 {
         GsdSmartcardManagerPrivate *priv = self->priv;
+        PK11SlotInfo *card_slot = NULL;
         GList *node;
 
         G_LOCK (gsd_smartcards_watch_tasks);
         node = priv->smartcards_watch_tasks;
         while (node != NULL) {
-                PK11SlotInfo *card_slot;
-
                 GTask *task = node->data;
                 WatchSmartcardsOperation *operation = g_task_get_task_data (task);
 
                 card_slot = get_login_token_for_operation (self, operation);
 
                 if (card_slot != NULL)
-                        return card_slot;
+                        break;
 
                 node = node->next;
         }
         G_UNLOCK (gsd_smartcards_watch_tasks);
 
-        return NULL;
+        return card_slot;
 }
 
 static GList *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]