md: fix possible corruption of array metadata on shutdown.
[~shefty/rdma-dev.git] / drivers / md / md.c
index 8beb19c..477eb2e 100644 (file)
@@ -8140,7 +8140,8 @@ static int md_notify_reboot(struct notifier_block *this,
 
        for_each_mddev(mddev, tmp) {
                if (mddev_trylock(mddev)) {
 
        for_each_mddev(mddev, tmp) {
                if (mddev_trylock(mddev)) {
-                       __md_stop_writes(mddev);
+                       if (mddev->pers)
+                               __md_stop_writes(mddev);
                        mddev->safemode = 2;
                        mddev_unlock(mddev);
                }
                        mddev->safemode = 2;
                        mddev_unlock(mddev);
                }