[PATCH] [keys] Use mutex instead of rw_semaphore for __key_link()serialisation

From: Arun Raghavan
Date: Sun Apr 13 2008 - 15:33:54 EST


__key_link() uses an rw_semaphore as a mutex to serialise link/link calls.
This patch converts it to explicitly use a struct mutex.

Signed-off-by: Arun Raghavan <arunsr@xxxxxxxxxxxxxx>
Signed-off-by: Satyam Sharma <satyam@xxxxxxxxxxxxx>

---

security/keys/keyring.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 5f31eb7..7bfc725 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/security.h>
#include <linux/seq_file.h>
+#include <linux/mutex.h>
#include <linux/err.h>
#include <asm/uaccess.h>
#include "internal.h"
@@ -69,10 +70,10 @@ struct key_type key_type_keyring = {
EXPORT_SYMBOL(key_type_keyring);

/*
- * semaphore to serialise link/link calls to prevent two link calls in parallel
+ * mutex to serialise link/link calls to prevent two link calls in parallel
* introducing a cycle
*/
-static DECLARE_RWSEM(keyring_serialise_link_sem);
+static DEFINE_MUTEX(keyring_serialise_link_mutex);

/*****************************************************************************/
/*
@@ -681,7 +682,7 @@ int __key_link(struct key *keyring, struct key *key)

/* serialise link/link calls to prevent parallel calls causing a
* cycle when applied to two keyring in opposite orders */
- down_write(&keyring_serialise_link_sem);
+ mutex_lock(&keyring_serialise_link_mutex);

/* check that we aren't going to create a cycle adding one keyring to
* another */
@@ -789,7 +790,7 @@ int __key_link(struct key *keyring, struct key *key)
done:
ret = 0;
error2:
- up_write(&keyring_serialise_link_sem);
+ mutex_unlock(&keyring_serialise_link_mutex);
error:
return ret;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/