Skip to contentSkip to conversation

fsck.f2fs: do umount to free memory in out_err

PATCH In review Junling Zheng 1 participant 2 messages May 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck.f2fs: do umount to free memory in out_err

Call f2fs_do_umount to free memory in out_err branch.

---
 fsck/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
fsck/main.c +1 -4
index c4dd8b1..870f2d8 100644
@@ -844,9 +844,6 @@ retry:
 	return 0;
 
 out_err:
-	if (sbi->ckpt)
-		free(sbi->ckpt);
-	if (sbi->raw_super)
-		free(sbi->raw_super);
+	f2fs_do_umount(sbi);
 	return ret;
 }
Signature · 6 lines
2.16.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#1 lore raw

Sorry, this patch has a bug:

If f2fs_do_mount fails in validate_super_block or get_valid_checkpoint, then we should only free sbi->ckpt and sbi->raw_super :(

Quoted 13 lines · Junling Zheng

Call f2fs_do_umount to free memory in out_err branch.

---
 fsck/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
fsck/main.c +0 -0
index c4dd8b1..870f2d8 100644

fsck/main.c retry: · line 849

Quoted 10 lines
fsck/main.c +1 -4
@@ -844,9 +844,6 @@ retry:
 	return 0;
 
 out_err:
-	if (sbi->ckpt)
-		free(sbi->ckpt);
-	if (sbi->raw_super)
-		free(sbi->raw_super);
+	f2fs_do_umount(sbi);
 	return ret;
 }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot