[PATCH 1/2] partitions: efi: use calloc instead of kzalloc
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Oct 22 01:33:46 PDT 2024
kzalloc() uses at least DMA_ALIGNMENT as alignment, which is more than
we need for the data structures that are used to hold the partition info.
Use the normal allocator to be more efficient with memory.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/partitions/efi.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 829360da6e1f..07944109ac89 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -92,7 +92,7 @@ static gpt_entry *alloc_read_gpt_entries(struct block_device *blk,
if (!count)
return NULL;
- pte = kzalloc(count, GFP_KERNEL);
+ pte = calloc(count, 1);
if (!pte)
return NULL;
@@ -100,7 +100,7 @@ static gpt_entry *alloc_read_gpt_entries(struct block_device *blk,
size = count / GPT_BLOCK_SIZE;
ret = block_read(blk, pte, from, size);
if (ret) {
- kfree(pte);
+ free(pte);
pte=NULL;
return NULL;
}
@@ -129,13 +129,13 @@ static gpt_header *alloc_read_gpt_header(struct block_device *blk,
unsigned ssz = bdev_logical_block_size(blk);
int ret;
- gpt = kzalloc(ssz, GFP_KERNEL);
+ gpt = calloc(ssz, 1);
if (!gpt)
return NULL;
ret = block_read(blk, gpt, lba, 1);
if (ret) {
- kfree(gpt);
+ free(gpt);
gpt=NULL;
return NULL;
}
@@ -227,10 +227,10 @@ static int is_gpt_valid(struct block_device *blk, u64 lba,
return 1;
fail_ptes:
- kfree(*ptes);
+ free(*ptes);
*ptes = NULL;
fail:
- kfree(*gpt);
+ free(*gpt);
*gpt = NULL;
return 0;
}
@@ -406,8 +406,8 @@ static int find_valid_gpt(void *buf, struct block_device *blk, gpt_header **gpt,
if (good_pgpt) {
*gpt = pgpt;
*ptes = pptes;
- kfree(agpt);
- kfree(aptes);
+ free(agpt);
+ free(aptes);
if (!good_agpt)
dev_warn(blk->dev, "Alternate GPT is invalid, using primary GPT.\n");
return 1;
@@ -415,17 +415,17 @@ static int find_valid_gpt(void *buf, struct block_device *blk, gpt_header **gpt,
else if (good_agpt) {
*gpt = agpt;
*ptes = aptes;
- kfree(pgpt);
- kfree(pptes);
+ free(pgpt);
+ free(pptes);
dev_warn(blk->dev, "Primary GPT is invalid, using alternate GPT.\n");
return 1;
}
fail:
- kfree(pgpt);
- kfree(agpt);
- kfree(pptes);
- kfree(aptes);
+ free(pgpt);
+ free(agpt);
+ free(pptes);
+ free(aptes);
*gpt = NULL;
*ptes = NULL;
return 0;
--
2.39.5
More information about the barebox
mailing list