nvram: fix memory leak
authorBangLang Huang <banglang.huang@foxmail.com>
Fri, 24 Feb 2017 02:16:17 +0000 (10:16 +0800)
committerAlexander Couzens <lynxis@fe80.eu>
Tue, 22 Aug 2017 12:31:32 +0000 (14:31 +0200)
commit1948d8e08c72106a01b359a30217cf92657cc79d
treebbc4501f33905e3baf69e8e908ae5ca68627939b
parente622b307307856d284addc52e8172fdf66252d96
nvram: fix memory leak

Fix memory leak on nvram_open() and nvram_open_rdonly().

For nvram_open(), the 'fd' should be closed on error, and
mmap_area should be unmap when nvram magic can not be found.

For nvram_open_rdonly(), the 'file' variable should free before
return. Once nvram_find_mtd() return successfully, it will allocate
memory to save mtd device string.

Signed-off-by: BangLang Huang <banglang.huang@foxmail.com>
package/utils/nvram/src/cli.c
package/utils/nvram/src/nvram.c