mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Fix uninitialized variable on unaligned SPI Xfer
We use a stack-allocated u32 to store a temporary word that gets memcpy'd from a potentially unaligned buffer, but the size of the copy could be less than 4 bytes, therefore leaving garbage in the upper bits of said word. This fixes CODEC in Corgi3DS.
This commit is contained in:
parent
d63db4bc6d
commit
65f6748dc1
@ -103,7 +103,7 @@ static void SPI_SingleXfer(u32 reg, u32 bus, void *buffer, u32 len, bool read)
|
|||||||
u32 tmp = REG_SPI(bus, REG_SPI_FIFO);
|
u32 tmp = REG_SPI(bus, REG_SPI_FIFO);
|
||||||
memcpy((u8 *) buffer + pos, &tmp, min(4, len - pos));
|
memcpy((u8 *) buffer + pos, &tmp, min(4, len - pos));
|
||||||
} else {
|
} else {
|
||||||
u32 tmp;
|
u32 tmp = 0;
|
||||||
memcpy(&tmp, (u8 *) buffer + pos, min(4, len - pos));
|
memcpy(&tmp, (u8 *) buffer + pos, min(4, len - pos));
|
||||||
REG_SPI(bus, REG_SPI_FIFO) = tmp;
|
REG_SPI(bus, REG_SPI_FIFO) = tmp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user