mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/7] sandbox: hostfile: strdup device tree node names
Date: Mon, 25 Nov 2024 16:29:21 +0100	[thread overview]
Message-ID: <20241125152927.546493-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241125152927.546493-1-a.fatoum@pengutronix.de>

Later commits will change struct device_node::name to have a type of
const char *, leading to a warning here.

A nicer fix would be to use strdup_const here, but this needs some more
work, so for now duplicate the string.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 7afad95b6d8b..9122ff9da2f1 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -156,7 +156,7 @@ static int hf_probe(struct device *dev)
 	cdev_set_of_node(cdev, np);
 
 	if (is_blockdev) {
-		cdev->name = np->name;
+		cdev->name = strdup(np->name);
 		priv->blk.dev = dev;
 		priv->blk.ops = &hf_blk_ops;
 		priv->blk.blockbits = SECTOR_SHIFT;
@@ -169,7 +169,7 @@ static int hf_probe(struct device *dev)
 
 		dev_info(dev, "registered as block device\n");
 	} else {
-		cdev->name = np->name;
+		cdev->name = strdup(np->name);
 		cdev->dev = dev;
 		cdev->ops = &hf_cdev_ops;
 		cdev->size = reg[1];
-- 
2.39.5




  reply	other threads:[~2024-11-25 15:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 15:29 [PATCH 0/7] add proper strdup_const support Ahmad Fatoum
2024-11-25 15:29 ` Ahmad Fatoum [this message]
2024-11-25 15:29 ` [PATCH 2/7] lds: implement is_barebox_rodata Ahmad Fatoum
2024-11-25 15:29 ` [PATCH 3/7] string: implement proper strdup_const/free_const Ahmad Fatoum
2024-11-25 15:29 ` [PATCH 4/7] treewide: replace basename with kbasename Ahmad Fatoum
2024-11-25 15:29 ` [PATCH 5/7] treewide: use strdup_const where appropriate Ahmad Fatoum
2024-11-25 15:29 ` [PATCH 6/7] fs: efi: replace allocation with local buffer Ahmad Fatoum
2024-11-25 15:29 ` [PATCH 7/7] cdev: fix string leaks in devfs links Ahmad Fatoum

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=20241125152927.546493-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@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