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 7/7] cdev: fix string leaks in devfs links
Date: Mon, 25 Nov 2024 16:29:27 +0100	[thread overview]
Message-ID: <20241125152927.546493-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241125152927.546493-1-a.fatoum@pengutronix.de>

The name and part of devfs links are always dynamically allocated, so
make sure to free them once we are done with them.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/devfs-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 0bb363d0a9ff..0651be3d8fc4 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -428,8 +428,11 @@ int devfs_remove(struct cdev *cdev)
 	if (cdev_is_partition(cdev))
 		list_del(&cdev->partition_entry);
 
-	if (cdev->link)
+	if (cdev->link) {
+		free(cdev->name);
+		free(cdev->partname);
 		free(cdev);
+	}
 
 	return 0;
 }
-- 
2.39.5




      parent 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 ` [PATCH 1/7] sandbox: hostfile: strdup device tree node names Ahmad Fatoum
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 ` Ahmad Fatoum [this message]

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