env: fix memory leak in fw_env routines
authorStefano Babic <sbabic@denx.de>
Wed, 5 Apr 2017 16:08:03 +0000 (18:08 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 12 Apr 2017 17:28:29 +0000 (13:28 -0400)
commit33f0086cb74628080bb4bcb565b25c8ea5299d79
tree6e699d84f62664df00e6bd2dc39d1e281330a279
parent00c234f38fccaa24b052691913cb3a7e8bc2b3a1
env: fix memory leak in fw_env routines

fw_env_open allocates buffers to store the environment, but these
buffers are never freed. This becomes quite nasty using the fw_ tools as
library, because each access to the environment (even just reading a
variable) generates a memory leak equal to the size of the environment.

Fix this renaming fw_env_close() as fw_env_flush(), because the function
really flushes the environment from RAM to storage, and add a
fw_env_close function to free the allocated resources.

Signed-off-by: Stefano Babic <sbabic@denx.de>
tools/env/fw_env.c
tools/env/fw_env.h