Blame SOURCES/autofs-5.1.7-add-ext_mount_hash_mutex-lock-helpers.patch

beb904
autofs-5.1.7 - add ext_mount_hash_mutex lock helpers
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
Coverity: check_return: Calling "pthread_mutex_lock" without checking
beb904
	  return value.
beb904
beb904
Well, I use helpers to do this in many places so can't really disagree.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG    |    1 +
beb904
 lib/mounts.c |   26 ++++++++++++++++++++------
beb904
 2 files changed, 21 insertions(+), 6 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -65,6 +65,7 @@
beb904
 - fix double free in parse_mapent().
beb904
 - refactor lookup_prune_one_cache() a bit.
beb904
 - cater for empty mounts list in mnts_get_expire_list().
beb904
+- add ext_mount_hash_mutex lock helpers.
beb904
 
beb904
 xx/xx/2018 autofs-5.1.5
beb904
 - fix flag file permission.
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -788,6 +788,20 @@ char *make_mnt_name_string(char *path)
beb904
 	return mnt_name;
beb904
 }
beb904
 
beb904
+static void ext_mount_hash_mutex_lock(void)
beb904
+{
beb904
+	int status = pthread_mutex_lock(&ext_mount_hash_mutex);
beb904
+	if (status)
beb904
+		fatal(status);
beb904
+}
beb904
+
beb904
+static void ext_mount_hash_mutex_unlock(void)
beb904
+{
beb904
+	int status = pthread_mutex_unlock(&ext_mount_hash_mutex);
beb904
+	if (status)
beb904
+		fatal(status);
beb904
+}
beb904
+
beb904
 static struct ext_mount *ext_mount_lookup(const char *mp)
beb904
 {
beb904
 	uint32_t hval = hash(mp, HASH_SIZE(ext_mounts_hash));
beb904
@@ -806,7 +820,7 @@ int ext_mount_add(const char *path, cons
beb904
 	struct ext_mount *em;
beb904
 	int ret = 0;
beb904
 
beb904
-	pthread_mutex_lock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_lock();
beb904
 
beb904
 	em = ext_mount_lookup(path);
beb904
 	if (em) {
beb904
@@ -840,7 +854,7 @@ int ext_mount_add(const char *path, cons
beb904
 
beb904
 	ret = 1;
beb904
 done:
beb904
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_unlock();
beb904
 	return ret;
beb904
 }
beb904
 
beb904
@@ -849,7 +863,7 @@ int ext_mount_remove(const char *path)
beb904
 	struct ext_mount *em;
beb904
 	int ret = 0;
beb904
 
beb904
-	pthread_mutex_lock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_lock();
beb904
 
beb904
 	em = ext_mount_lookup(path);
beb904
 	if (!em)
beb904
@@ -867,7 +881,7 @@ int ext_mount_remove(const char *path)
beb904
 		ret = 1;
beb904
 	}
beb904
 done:
beb904
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_unlock();
beb904
 	return ret;
beb904
 }
beb904
 
beb904
@@ -876,13 +890,13 @@ int ext_mount_inuse(const char *path)
beb904
 	struct ext_mount *em;
beb904
 	int ret = 0;
beb904
 
beb904
-	pthread_mutex_lock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_lock();
beb904
 	em = ext_mount_lookup(path);
beb904
 	if (!em)
beb904
 		goto done;
beb904
 	ret = em->ref;
beb904
 done:
beb904
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
beb904
+	ext_mount_hash_mutex_unlock();
beb904
 	return ret;
beb904
 }
beb904