summaryrefslogtreecommitdiff
path: root/fs/pstore
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2020-05-04 19:31:36 -0700
committerKees Cook <keescook@chromium.org>2020-05-12 09:13:47 -0700
commitcab12fd049380b1d0c3ac9f534407a8cc0ac4bba (patch)
treefbeece16030bf753ffc420a5e496ca0ce0ea2c6a /fs/pstore
parentc30b20cd96a7a08e77c12cb3326c6fd801f7fe87 (diff)
pstore: Convert "psinfo" locking to mutex
Currently pstore can only have a single backend attached at a time, and it tracks the active backend via "psinfo", under a lock. The locking for this does not need to be a spinlock, and in order to avoid may_sleep() issues during future changes to pstore_unregister(), switch to a mutex instead. Link: https://lore.kernel.org/lkml/20200506152114.50375-4-keescook@chromium.org/ Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/platform.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 347b6c07f4cf..d0ce22237589 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -72,7 +72,7 @@ static DECLARE_WORK(pstore_work, pstore_dowork);
* psinfo_lock just protects "psinfo" during
* calls to pstore_register()
*/
-static DEFINE_SPINLOCK(psinfo_lock);
+static DEFINE_MUTEX(psinfo_lock);
struct pstore_info *psinfo;
static char *backend;
@@ -574,11 +574,11 @@ int pstore_register(struct pstore_info *psi)
return -EINVAL;
}
- spin_lock(&psinfo_lock);
+ mutex_lock(&psinfo_lock);
if (psinfo) {
pr_warn("backend '%s' already loaded: ignoring '%s'\n",
psinfo->name, psi->name);
- spin_unlock(&psinfo_lock);
+ mutex_unlock(&psinfo_lock);
return -EBUSY;
}
@@ -587,7 +587,7 @@ int pstore_register(struct pstore_info *psi)
psinfo = psi;
mutex_init(&psinfo->read_mutex);
sema_init(&psinfo->buf_lock, 1);
- spin_unlock(&psinfo_lock);
+ mutex_unlock(&psinfo_lock);
if (psi->flags & PSTORE_FLAGS_DMESG)