Skip to content

Commit cab12fd

Browse files
committed
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/[email protected]/ Signed-off-by: Kees Cook <[email protected]>
1 parent c30b20c commit cab12fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/pstore/platform.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static DECLARE_WORK(pstore_work, pstore_dowork);
7272
* psinfo_lock just protects "psinfo" during
7373
* calls to pstore_register()
7474
*/
75-
static DEFINE_SPINLOCK(psinfo_lock);
75+
static DEFINE_MUTEX(psinfo_lock);
7676
struct pstore_info *psinfo;
7777

7878
static char *backend;
@@ -574,11 +574,11 @@ int pstore_register(struct pstore_info *psi)
574574
return -EINVAL;
575575
}
576576

577-
spin_lock(&psinfo_lock);
577+
mutex_lock(&psinfo_lock);
578578
if (psinfo) {
579579
pr_warn("backend '%s' already loaded: ignoring '%s'\n",
580580
psinfo->name, psi->name);
581-
spin_unlock(&psinfo_lock);
581+
mutex_unlock(&psinfo_lock);
582582
return -EBUSY;
583583
}
584584

@@ -587,7 +587,7 @@ int pstore_register(struct pstore_info *psi)
587587
psinfo = psi;
588588
mutex_init(&psinfo->read_mutex);
589589
sema_init(&psinfo->buf_lock, 1);
590-
spin_unlock(&psinfo_lock);
590+
mutex_unlock(&psinfo_lock);
591591

592592

593593
if (psi->flags & PSTORE_FLAGS_DMESG)

0 commit comments

Comments
 (0)