f2fs: hanlde error case in f2fs_ioc_shutdown
authorChao Yu <yuchao0@huawei.com>
Wed, 17 Jan 2018 14:28:52 +0000 (22:28 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 27 Jan 2018 21:30:31 +0000 (13:30 -0800)
This patch makes f2fs_ioc_shutdown handling error case correctly.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index a04132b72991ede851f61dd66ebc3cf8b822e34e..038aca3c7207cfd00a856670768fae635fbf73eb 100644 (file)
@@ -1838,14 +1838,20 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
        switch (in) {
        case F2FS_GOING_DOWN_FULLSYNC:
                sb = freeze_bdev(sb->s_bdev);
-               if (sb && !IS_ERR(sb)) {
+               if (IS_ERR(sb)) {
+                       ret = PTR_ERR(sb);
+                       goto out;
+               }
+               if (sb) {
                        f2fs_stop_checkpoint(sbi, false);
                        thaw_bdev(sb->s_bdev, sb);
                }
                break;
        case F2FS_GOING_DOWN_METASYNC:
                /* do checkpoint only */
-               f2fs_sync_fs(sb, 1);
+               ret = f2fs_sync_fs(sb, 1);
+               if (ret)
+                       goto out;
                f2fs_stop_checkpoint(sbi, false);
                break;
        case F2FS_GOING_DOWN_NOSYNC: