summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHector Palacios <hector.palacios@digi.com>2014-02-13 09:48:24 +0100
committerTom Rini <trini@ti.com>2014-02-24 10:56:07 -0500
commit61fcc7d2757bc5d6bf52739e4fc7132b5fa84efe (patch)
tree962b8e81b6692c5266694597d674f531f9aa0887
parent1674df60d17e0e72396c961d5390bb62b184ad95 (diff)
downloadtalos-obmc-uboot-61fcc7d2757bc5d6bf52739e4fc7132b5fa84efe.tar.gz
talos-obmc-uboot-61fcc7d2757bc5d6bf52739e4fc7132b5fa84efe.zip
part_efi: fix protective mbr struct allocation
The calloc() call was allocating space for the sizeof the struct pointer rather than for the struct contents. Besides, since this buffer is passed to mmc for writing and some platforms may use cache, the legacy_mbr struct should be cache-aligned. Signed-off-by: Hector Palacios <hector.palacios@digi.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
-rw-r--r--disk/part_efi.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 9c33ae7a31..733d5bde94 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -213,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;
@@ -231,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;
}
OpenPOWER on IntegriCloud