]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - disk/part_efi.c
part_efi: fix protective mbr struct allocation
[karo-tx-uboot.git] / disk / part_efi.c
index b7524d68ba05b570e2286aeb208e2e15ab030f38..733d5bde94ed416e0831d326a0e865c56edc02b8 100644 (file)
@@ -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;
        }
 
@@ -212,10 +213,10 @@ int test_part_efi(block_dev_desc_t * dev_desc)
  */
 static int set_protective_mbr(block_dev_desc_t *dev_desc)
 {
-       legacy_mbr *p_mbr;
-
        /* Setup the Protective MBR */
-       p_mbr = calloc(1, sizeof(p_mbr));
+       ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, p_mbr, 1);
+       memset(p_mbr, 0, sizeof(*p_mbr));
+
        if (p_mbr == NULL) {
                printf("%s: calloc failed!\n", __func__);
                return -1;
@@ -230,11 +231,9 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc)
        if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) {
                printf("** Can't write to device %d **\n",
                        dev_desc->dev);
-               free(p_mbr);
                return -1;
        }
 
-       free(p_mbr);
        return 0;
 }