aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/nvram/src/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/utils/nvram/src/cli.c')
-rw-r--r--package/utils/nvram/src/cli.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/package/utils/nvram/src/cli.c b/package/utils/nvram/src/cli.c
index 488d641cfc..4f9c77804d 100644
--- a/package/utils/nvram/src/cli.c
+++ b/package/utils/nvram/src/cli.c
@@ -27,13 +27,17 @@
static nvram_handle_t * nvram_open_rdonly(void)
{
- const char *file = nvram_find_staging();
+ char *file = nvram_find_staging();
if( file == NULL )
file = nvram_find_mtd();
- if( file != NULL )
- return nvram_open(file, NVRAM_RO);
+ if( file != NULL ) {
+ nvram_handle_t *h = nvram_open(file, NVRAM_RO);
+ if( strcmp(file, NVRAM_STAGING) )
+ free(file);
+ return h;
+ }
return NULL;
}