mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH master] device: use free_const to free device/bobject name
Date: Thu, 13 Nov 2025 12:08:31 +0100	[thread overview]
Message-ID: <20251113110831.2262580-1-s.hauer@pengutronix.de> (raw)

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




             reply	other threads:[~2025-11-13 11:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 11:08 Sascha Hauer [this message]
2025-11-17  8:36 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251113110831.2262580-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox