[PATCH master] device: use free_const to free device/bobject name
Sascha Hauer
s.hauer at pengutronix.de
Thu Nov 13 03:08:31 PST 2025
A device name (and thus a bobject name) may be statically allocated. Use
free_const() to handle this gracefully.
bobject_set_name() called from dev_set_name() also assumes that
dev->name is allocated and frees the existing name. Use free_const()
here as well.
Fixes: 1e91e857bf ("bobject: free object name in bobject_del()")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
lib/bobject.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/bobject.c b/lib/bobject.c
index 373575eade..02cf6926c1 100644
--- a/lib/bobject.c
+++ b/lib/bobject.c
@@ -29,7 +29,7 @@ int bobject_set_name(bobject_t bobj, const char *fmt, ...)
* Free old pointer, we do this after vasprintf call in case
* old device name was in one of vargs
*/
- free(oldname);
+ free_const(oldname);
return WARN_ON(err < 0) ? err : 0;
}
@@ -68,6 +68,6 @@ void bobject_del(struct bobject *bobj)
list_for_each_entry_safe(p, n, &bobj->parameters, list)
param_remove(p);
- free(bobj->name);
+ free_const(bobj->name);
}
EXPORT_SYMBOL(bobject_del);
--
2.47.3
More information about the barebox
mailing list