summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-02-15 08:47:52 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-02-16 12:04:42 +0100
commit729370043ab67efc82b2574a8dc88b82a99f986c (patch)
treec7dbd01113a0c5c3e60865b87908de24f8a4e46c /common
parentd84c3daf13145dacced3f32e56ef006e824059c5 (diff)
downloadbarebox-729370043ab67efc82b2574a8dc88b82a99f986c.tar.gz
barebox-729370043ab67efc82b2574a8dc88b82a99f986c.tar.xz
common: partitions: efi: fix memory leak
In efi_partition() gpt and ptes is allocated but never freed. It's no longer used when leaving this function, so free the memory before leaving it. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20240215074757.960200-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/partitions/efi.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 0add66e6e4..d0e14d5abb 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -440,11 +440,8 @@ static void efi_partition(void *buf, struct block_device *blk,
int nb_part;
struct partition *pentry;
- if (!find_valid_gpt(buf, blk, &gpt, &ptes) || !gpt || !ptes) {
- kfree(gpt);
- kfree(ptes);
- return;
- }
+ if (!find_valid_gpt(buf, blk, &gpt, &ptes) || !gpt || !ptes)
+ goto out;
snprintf(blk->cdev.diskuuid, sizeof(blk->cdev.diskuuid), "%pUl", &gpt->disk_guid);
dev_add_param_string_fixed(blk->dev, "guid", blk->cdev.diskuuid);
@@ -474,6 +471,9 @@ static void efi_partition(void *buf, struct block_device *blk,
pentry->typeuuid = ptes[i].partition_type_guid;
pd->used_entries++;
}
+out:
+ kfree(gpt);
+ kfree(ptes);
}
static struct partition_parser efi_partition_parser = {