Clean up the lock in gss_krb5int_import_cred
authorGreg Hudson <ghudson@mit.edu>
Sat, 23 Jul 2011 13:15:09 +0000 (13:15 +0000)
committerGreg Hudson <ghudson@mit.edu>
Sat, 23 Jul 2011 13:15:09 +0000 (13:15 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25040 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/acquire_cred.c

index df029cc32e8cd9456af3e7038dddc75bc21ffec5..055b3eb4c59d7317db67f9944dc3aa7da544b110 100644 (file)
@@ -845,6 +845,17 @@ gss_krb5int_import_cred(OM_uint32 *minor_status,
 
     memset(&args, 0, sizeof(args));
 
+    if (req->id && req->keytab)
+        args.cred_usage = GSS_C_BOTH;
+    else if (req->id)
+        args.cred_usage = GSS_C_INITIATE;
+    else if (req->keytab)
+        args.cred_usage = GSS_C_ACCEPT;
+    else {
+        *minor_status = EINVAL;
+        return GSS_S_FAILURE;
+    }
+
     if (req->keytab_principal) {
         memset(&name, 0, sizeof(name));
         code = k5_mutex_init(&name.lock);
@@ -859,17 +870,9 @@ gss_krb5int_import_cred(OM_uint32 *minor_status,
     args.ccache = req->id;
     args.keytab = req->keytab;
 
-    if (req->id && req->keytab)
-        args.cred_usage = GSS_C_BOTH;
-    else if (req->id)
-        args.cred_usage = GSS_C_INITIATE;
-    else if (req->keytab)
-        args.cred_usage = GSS_C_ACCEPT;
-    else {
-        *minor_status = EINVAL;
-        return GSS_S_FAILURE;
-    }
-
-    return acquire_cred(minor_status, &args, cred_handle, &time_rec);
+    code = acquire_cred(minor_status, &args, cred_handle, &time_rec);
+    if (req->keytab_principal)
+        k5_mutex_destroy(&name.lock);
+    return code;
 }