8f2508
diff -up nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig nfs-utils-2.3.3/utils/gssd/krb5_util.c
8f2508
--- nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig	2021-07-22 15:27:27.728680553 -0400
8f2508
+++ nfs-utils-2.3.3/utils/gssd/krb5_util.c	2021-07-22 15:30:08.916979585 -0400
8f2508
@@ -165,18 +165,28 @@ static int gssd_get_single_krb5_cred(krb
8f2508
 static int query_krb5_ccache(const char* cred_cache, char **ret_princname,
8f2508
 		char **ret_realm);
8f2508
 
8f2508
-static void release_ple(krb5_context context, struct gssd_k5_kt_princ *ple)
8f2508
+static void release_ple_locked(krb5_context context,
8f2508
+			       struct gssd_k5_kt_princ *ple)
8f2508
 {
8f2508
 	if (--ple->refcount)
8f2508
 		return;
8f2508
 
8f2508
-	printerr(3, "freeing cached principal (ccname=%s, realm=%s)\n", ple->ccname, ple->realm);
8f2508
+	printerr(3, "freeing cached principal (ccname=%s, realm=%s)\n",
8f2508
+		 ple->ccname, ple->realm);
8f2508
 	krb5_free_principal(context, ple->princ);
8f2508
 	free(ple->ccname);
8f2508
 	free(ple->realm);
8f2508
 	free(ple);
8f2508
 }
8f2508
 
8f2508
+static void release_ple(krb5_context context, struct gssd_k5_kt_princ *ple)
8f2508
+{
8f2508
+	pthread_mutex_lock(&ple_lock);
8f2508
+	release_ple_locked(context, ple);
8f2508
+	pthread_mutex_unlock(&ple_lock);
8f2508
+}
8f2508
+
8f2508
+
8f2508
 /*
8f2508
  * Called from the scandir function to weed out potential krb5
8f2508
  * credentials cache files
8f2508
@@ -1396,7 +1406,7 @@ gssd_destroy_krb5_principals(int destroy
8f2508
 			}
8f2508
 		}
8f2508
 
8f2508
-		release_ple(context, ple);
8f2508
+		release_ple_locked(context, ple);
8f2508
 	}
8f2508
 	pthread_mutex_unlock(&ple_lock);
8f2508
 	krb5_free_context(context);