nvram: fix memory leak
authorBangLang Huang <banglang.huang@foxmail.com>
Fri, 24 Feb 2017 02:16:17 +0000 (10:16 +0800)
committerJo-Philipp Wich <jo@mein.io>
Wed, 13 Dec 2017 15:23:39 +0000 (16:23 +0100)
commit9e84d333b19abdfe5effd276421217a64dd98078
tree82637d00f95d4eb5308ded578cf95a7d0e891c28
parent3b6b892d675fdb724fb523fa8a14cf0e8068f959
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>
(cherry picked from commit 1948d8e08c72106a01b359a30217cf92657cc79d)
package/utils/nvram/src/cli.c
package/utils/nvram/src/nvram.c