Commit a72cbf83 authored by Song Liu's avatar Song Liu Committed by Shaohua Li

md/r5cache: call mddev_lock/unlock() in r5c_journal_mode_show

In r5c_journal_mode_show(), it is necessary to call mddev_lock()
before accessing conf and conf->log. Otherwise, the conf->log
may change (and become NULL).
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent 26e13043
...@@ -2529,11 +2529,18 @@ static void r5l_write_super(struct r5l_log *log, sector_t cp) ...@@ -2529,11 +2529,18 @@ static void r5l_write_super(struct r5l_log *log, sector_t cp)
static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page) static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
{ {
struct r5conf *conf = mddev->private; struct r5conf *conf;
int ret; int ret;
if (!conf->log) ret = mddev_lock(mddev);
if (ret)
return ret;
conf = mddev->private;
if (!conf || !conf->log) {
mddev_unlock(mddev);
return 0; return 0;
}
switch (conf->log->r5c_journal_mode) { switch (conf->log->r5c_journal_mode) {
case R5C_JOURNAL_MODE_WRITE_THROUGH: case R5C_JOURNAL_MODE_WRITE_THROUGH:
...@@ -2551,6 +2558,7 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page) ...@@ -2551,6 +2558,7 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
default: default:
ret = 0; ret = 0;
} }
mddev_unlock(mddev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment