[PATCH 1/2] md/r5cache: fix r5c_journal_mode_store

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In r5c_journal_mode_store(), conf->log may change (and become NULL)
after mddev_suspend(). This patch check conf->log again after
mddev_suspend() to mitigate this risk.

Signed-off-by: Song Liu <songliubraving@xxxxxx>
---
 drivers/md/raid5-cache.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index bfa1e90..315cabf 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -2541,9 +2541,8 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
 int r5c_journal_mode_set(struct mddev *mddev, int mode)
 {
 	struct r5conf *conf = mddev->private;
-	struct r5l_log *log = conf->log;
 
-	if (!log)
+	if (!conf->log)
 		return -ENODEV;
 
 	if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH ||
@@ -2555,6 +2554,10 @@ int r5c_journal_mode_set(struct mddev *mddev, int mode)
 		return -EINVAL;
 
 	mddev_suspend(mddev);
+	if (!conf || !conf->log) {
+		mddev_resume(mddev);
+		return -ENODEV;
+	}
 	conf->log->r5c_journal_mode = mode;
 	mddev_resume(mddev);
 
-- 
2.9.3

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



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux