Patchwork [U-Boot,1/6] part_efi: make sure the gpt_pte is freed

login
register
mail settings
Submitter Mark Langsdorf
Date Sept. 10, 2013, 8:14 p.m.
Message ID <1378844096-15259-1-git-send-email-mark.langsdorf@calxeda.com>
Download mbox | patch
Permalink /patch/274038/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Mark Langsdorf - Sept. 10, 2013, 8:14 p.m.
the gpt_pte wasn't being freed if it was checked against an invalid
partition. The resulting memory leakage could make it impossible
to repeatedly attempt to load non-existent files in a script.

Also, downgrade the message for not finding an invalid partition
from a printf() to a debug() so as to minimize message spam in
perfectly normal situations.

Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
---
 disk/part_efi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Tom Rini - Sept. 21, 2013, 12:06 p.m.
On Tue, Sep 10, 2013 at 03:14:56PM -0500, Mark Langsdorf wrote:

> the gpt_pte wasn't being freed if it was checked against an invalid
> partition. The resulting memory leakage could make it impossible
> to repeatedly attempt to load non-existent files in a script.
> 
> Also, downgrade the message for not finding an invalid partition
> from a printf() to a debug() so as to minimize message spam in
> perfectly normal situations.
> 
> Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/disk/part_efi.c b/disk/part_efi.c
index b7524d6..9c33ae7 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -164,8 +164,9 @@  int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 
 	if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
 	    !is_pte_valid(&gpt_pte[part - 1])) {
-		printf("%s: *** ERROR: Invalid partition number %d ***\n",
+		debug("%s: *** ERROR: Invalid partition number %d ***\n",
 			__func__, part);
+		free(gpt_pte);
 		return -1;
 	}