From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] partitions: efi: remove guid device parameter on free
Date: Mon, 25 Nov 2024 16:27:55 +0100 [thread overview]
Message-ID: <20241125152756.513705-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241125152756.513705-1-a.fatoum@pengutronix.de>
The leak doesn't bother us normally, but when fuzzing it quickly adds
up, so let's fix it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/partitions/efi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index d4a7ee5d4471..968b959397b5 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -26,6 +26,7 @@ struct efi_partition_desc {
struct partition_desc pd;
gpt_header *gpt;
gpt_entry *ptes;
+ struct param_d *param_guid;
};
struct efi_partition {
@@ -513,9 +514,6 @@ static struct partition_desc *efi_partition(void *buf, struct block_device *blk)
if (!find_valid_gpt(buf, blk, &gpt, &ptes) || !gpt || !ptes)
return NULL;
- snprintf(blk->cdev.diskuuid, sizeof(blk->cdev.diskuuid), "%pUl", &gpt->disk_guid);
- dev_add_param_string_fixed(blk->dev, "guid", blk->cdev.diskuuid);
-
blk->cdev.flags |= DEVFS_IS_GPT_PARTITIONED;
nb_part = le32_to_cpu(gpt->num_partition_entries);
@@ -532,6 +530,10 @@ static struct partition_desc *efi_partition(void *buf, struct block_device *blk)
epd->gpt = gpt;
epd->ptes = ptes;
+ snprintf(blk->cdev.diskuuid, sizeof(blk->cdev.diskuuid), "%pUl", &gpt->disk_guid);
+ epd->param_guid = dev_add_param_string_fixed(blk->dev,
+ "guid", blk->cdev.diskuuid);
+
for (i = 0; i < nb_part; i++) {
if (!is_pte_valid(&ptes[i], last_lba(blk))) {
dev_dbg(blk->dev, "Invalid pte %d\n", i);
@@ -566,6 +568,7 @@ static void efi_partition_free(struct partition_desc *pd)
free(epart);
}
+ dev_remove_param(epd->param_guid);
free(epd->ptes);
free(epd->gpt);
free(epd);
--
2.39.5
next prev parent reply other threads:[~2024-11-25 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 15:27 [PATCH 1/3] partitions: dos: fix memory leaks Ahmad Fatoum
2024-11-25 15:27 ` Ahmad Fatoum [this message]
2024-11-25 15:27 ` [PATCH 3/3] partitions: efi: remove unnecessary NULLing of local variable 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=20241125152756.513705-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