diff mbox series

[U-Boot] part: Allocate only one legacy_mbr buffer

Message ID 20180129195824.737-1-abrodkin@synopsys.com
State Accepted
Commit 8639e34d2c5e12cc2e45c95b1a2e97c22bf6a711
Delegated to: Tom Rini
Headers show
Series [U-Boot] part: Allocate only one legacy_mbr buffer | expand

Commit Message

Alexey Brodkin Jan. 29, 2018, 7:58 p.m. UTC
Commit ff98cb90514d ("part: extract MBR signature from partitions")
blindly switched allocated by ALLOC_CACHE_ALIGN_BUFFER buffer type from
"unsigned char" to "legacy_mbr" which caused allocation of size =
(typeof(legacy_mbr) * dev_desc->blksize) instead of just space enough
for "legacy_mbr" structure.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
Cc: Tom Rini <trini@konsulko.com>
---
 disk/part_dos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini Feb. 8, 2018, 12:27 p.m. UTC | #1
On Mon, Jan 29, 2018 at 10:58:24PM +0300, Alexey Brodkin wrote:

> Commit ff98cb90514d ("part: extract MBR signature from partitions")
> blindly switched allocated by ALLOC_CACHE_ALIGN_BUFFER buffer type from
> "unsigned char" to "legacy_mbr" which caused allocation of size =
> (typeof(legacy_mbr) * dev_desc->blksize) instead of just space enough
> for "legacy_mbr" structure.
> 
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Peter Jones <pjones@redhat.com>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/disk/part_dos.c b/disk/part_dos.c
index 046f9bbb3d69..9dd086d3db06 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -90,7 +90,7 @@  static int test_block_type(unsigned char *buffer)
 static int part_test_dos(struct blk_desc *dev_desc)
 {
 #ifndef CONFIG_SPL_BUILD
-	ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
+	ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, 1);
 
 	if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1)
 		return -1;