[PATCH] param: add error check to dev_param_set_generic()
Masahiro Yamada
yamada.m at jp.panasonic.com
Wed Jan 28 18:42:13 PST 2015
The function dev_param_set_generic() may fail because of
out of memory. If so, return -ENOMEM.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
lib/parameter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/parameter.c b/lib/parameter.c
index d337ef3..71262c4 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -114,7 +114,7 @@ int dev_param_set_generic(struct device_d *dev, struct param_d *p,
return 0;
}
p->value = strdup(val);
- return 0;
+ return p->value ? 0 : -ENOMEM;
}
static const char *param_get_generic(struct device_d *dev, struct param_d *p)
--
1.9.1
More information about the barebox
mailing list