Skip to contentSkip to conversation

part: Allocate only one legacy_mbr buffer

PATCH In review Alexey Brodkin 2 participants 2 messages Jan 29, 2018 – Feb 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 part: Allocate only one legacy_mbr buffer

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.

Cc Rob Clark <[email protected]>
Cc Peter Jones <[email protected]>
Cc Alexander Graf <[email protected]>
Cc Tom Rini <[email protected]>
---
 disk/part_dos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disk/part_dos.c +1 -1
index 046f9bbb3d69..9dd086d3db06 100644
@@ -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;
Signature · 1 line
2.14.3
#1 lore raw
Quoted 11 lines · Alexey Brodkin

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.

Cc Rob Clark <[email protected]>
Cc Peter Jones <[email protected]>
Cc Alexander Graf <[email protected]>
Cc Tom Rini <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/eee57c48/attachment.sig>