summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-11-23 21:47:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-12-01 12:33:33 +0100
commitfa4c41ba60af6e8260307fadcd5fb68f8bdb7360 (patch)
treefbbd12d250019f61004906f194ec56e1f3e687ab
parent3edbc17f1ab1a13b6ddd7fcb4dee596ab41ae0b1 (diff)
downloadbarebox-fa4c41ba60af6e8260307fadcd5fb68f8bdb7360.tar.gz
nvvar: when setting a nvvar to NULL just free the content
When a nvvar is about to be removed then it is set to NULL by barebox. This means for the variable to free it's memory. In this case also do not pass the value to the corresponding globalvar, since that would set the globalvar to NULL aswell, but we want to keep its current value. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/globalvar.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/globalvar.c b/common/globalvar.c
index fdfaf76..5fa74a6 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -167,8 +167,10 @@ static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
{
int ret;
- if (!val)
- val = "";
+ if (!val) {
+ free(p->value);
+ return 0;
+ }
ret = dev_set_param(&global_device, p->name, val);
if (ret)