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

101 lines
2.4 KiB
Diff
Raw Normal View History

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