Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb042ec3 authored by Wei Fang's avatar Wei Fang Committed by Brian Norris
Browse files

jffs2: fix a memleak in read_direntry()



Need to free the memory allocated for 'fd' if failed to read all
of the remainder name.

Signed-off-by: default avatarWei Fang <fangwei1@huawei.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent d54e8801
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -660,8 +660,12 @@ static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_r

		err = jffs2_flash_read(c, (ref_offset(ref)) + read,
				rd->nsize - already, &read, &fd->name[already]);
		if (unlikely(read != rd->nsize - already) && likely(!err))
		if (unlikely(read != rd->nsize - already) && likely(!err)) {
			jffs2_free_full_dirent(fd);
			JFFS2_ERROR("short read: wanted %d bytes, got %zd\n",
				    rd->nsize - already, read);
			return -EIO;
		}

		if (unlikely(err)) {
			JFFS2_ERROR("read remainder of name: error %d\n", err);