[PATCH 02/21] nvvar: when setting a nvvar to NULL just free the content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 common/globalvar.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index ee756e5140..59d299f019 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)
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux