1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

Fix out-of-bounds ICH FREG permission printing

A bit was masked, but not shifted, and that led to worst-case accesses
of index 24 in an array with 4 members.

I've improved readability in the variable declaration block as well.

Thanks to Stephen Kou for reporting the bug.

Corresponding to flashrom svn r1076.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stephen Kou <stephen@hyarros.com>
This commit is contained in:
Carl-Daniel Hailfinger
2010-07-13 00:04:52 +00:00
parent 550f5c836c
commit ab922779e3

View File

@ -452,10 +452,11 @@ static void do_ich9_spi_frap(uint32_t frap, int i)
"Flash Descriptor", "BIOS", "Management Engine",
"Gigabit Ethernet", "Platform Data"
};
int rwperms = ((ICH_BRWA(frap) & (1 << i)) << 1) |
((ICH_BRRA(frap) & (1 << i)) << 0);
uint32_t base, limit;
int rwperms = (((ICH_BRWA(frap) >> i) & 1) << 1) |
(((ICH_BRRA(frap) >> i) & 1) << 0);
int offset = 0x54 + i * 4;
uint32_t freg = mmio_readl(ich_spibar + offset), base, limit;
uint32_t freg = mmio_readl(ich_spibar + offset);
msg_pdbg("0x%02X: 0x%08x (FREG%i: %s)\n",
offset, freg, i, region_names[i]);