diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 91fac54..1c618fa 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1536,6 +1536,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
 	dbg_save_space_info(c);
 	c->remounting_rw = 1;
 	c->always_chk_crc = 1;
+	c->ro_mount = 0;
 
 	err = check_free_space(c);
 	if (err)
@@ -1640,7 +1641,6 @@ static int ubifs_remount_rw(struct ubifs_info *c)
 	}
 
 	dbg_gen("re-mounted read-write");
-	c->ro_mount = 0;
 	c->remounting_rw = 0;
 	c->always_chk_crc = 0;
 	err = dbg_check_space_info(c);
@@ -1648,6 +1648,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
 	return err;
 
 out:
+	c->ro_mount = 1;
 	vfree(c->orph_buf);
 	c->orph_buf = NULL;
 	if (c->bgt) {
