diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index 7c2bac914bb46b37a14b4623d6dcd38ac0d34873..0f2585de61fe6ab0f95b70ebbaef0dddbd0f0635 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -232,9 +232,11 @@ static ssize_t sbi_cmd_store(struct kobject *kobj, struct sbi_attribute *attr, hmdfs_err("Illegal cmd : cmd = %d", cmd); return len; } + mutex_lock(&sbi->cmd_handler_mutex); hmdfs_info("Recved cmd: %s", cmd2str(cmd)); if (cmd_handler[cmd]) cmd_handler[cmd](buf, len, sbi); + mutex_unlock(&sbi->cmd_handler_mutex); return len; } diff --git a/fs/hmdfs/hmdfs.h b/fs/hmdfs/hmdfs.h index 9157c55ba3927da555d2ddfa2d12f24de8f2ea40..45fcf9f9b3f3b12c360e223ca0667c6f50cc25f4 100644 --- a/fs/hmdfs/hmdfs.h +++ b/fs/hmdfs/hmdfs.h @@ -169,6 +169,7 @@ struct hmdfs_sb_info { /* To bridge the userspace utils */ struct kfifo notify_fifo; spinlock_t notify_fifo_lock; + struct mutex cmd_handler_mutex; /* For reboot detect */ uint64_t boot_cookie; diff --git a/fs/hmdfs/main.c b/fs/hmdfs/main.c index d0a41061bb2f343317232f54e8a4d8255c1e5673..f321391e15f1c962449f26dee76bb135f9d0034a 100644 --- a/fs/hmdfs/main.c +++ b/fs/hmdfs/main.c @@ -692,6 +692,7 @@ static int hmdfs_init_sbi(struct hmdfs_sb_info *sbi) ret = 0; spin_lock_init(&sbi->notify_fifo_lock); + mutex_init(&sbi->cmd_handler_mutex); sbi->s_case_sensitive = false; sbi->s_features = HMDFS_FEATURE_READPAGES | HMDFS_FEATURE_READPAGES_OPEN |