mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] device: use free_const to free device/bobject name
@ 2025-11-13 11:08 Sascha Hauer
  2025-11-17  8:36 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2025-11-13 11:08 UTC (permalink / raw)
  To: Barebox List

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] device: use free_const to free device/bobject name
  2025-11-13 11:08 [PATCH master] device: use free_const to free device/bobject name Sascha Hauer
@ 2025-11-17  8:36 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-11-17  8:36 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Thu, 13 Nov 2025 12:08:31 +0100, Sascha Hauer wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] device: use free_const to free device/bobject name
      https://git.pengutronix.de/cgit/barebox/commit/?id=6c6f7301c4f3 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-17  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-13 11:08 [PATCH master] device: use free_const to free device/bobject name Sascha Hauer
2025-11-17  8:36 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox