[PATCH] f2fs: fix memory leak in build_directory

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

 



This patch fix bug that variable dentries going
out of scope leaks the storage it points to.

Signed-off-by: Xiaojun Wang<wangxiaojun11@xxxxxxxxxx>
---
 fsck/sload.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fsck/sload.c b/fsck/sload.c
index f5a4651..e5de2e1 100644
--- a/fsck/sload.c
+++ b/fsck/sload.c
@@ -240,15 +240,18 @@ static int build_directory(struct f2fs_sb_info *sbi, const char *full_path,
 		ret = set_selinux_xattr(sbi, dentries[i].path,
 					dentries[i].ino, dentries[i].mode);
 		if (ret)
-			return ret;
+			goto out;
+	}
 
+out:
+	for (i = 0; i < entries; i++) {
 		free(dentries[i].path);
 		free(dentries[i].full_path);
 		free((void *)dentries[i].name);
 	}
 
 	free(dentries);
-	return 0;
+	return ret;
 }
 
 static int configure_files(void)
-- 
2.7.4




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux