From fa4c41ba60af6e8260307fadcd5fb68f8bdb7360 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 23 Nov 2017 21:47:13 +0100 Subject: 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 --- common/globalvar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/globalvar.c b/common/globalvar.c index fdfaf76fae..5fa74a68cf 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) -- cgit v1.2.3