AP_Networking: panic if bad memory alignment

This commit is contained in:
bugobliterator 2023-08-02 16:54:43 +10:00 committed by Andrew Tridgell
parent cf6fd6717b
commit 724b0908e0
1 changed files with 5 additions and 0 deletions

View File

@ -194,6 +194,11 @@ static bool allocate_buffers()
rasr++; rasr++;
} }
void *mem = malloc_eth_safe(size); void *mem = malloc_eth_safe(size);
// ensure our memory is aligned
// ref. Cortex-M7 peripherals PM0253, section 4.6.4 MPU region base address register
if (((uint32_t)mem) % size) {
AP_HAL::panic("Bad alignment of ETH memory");
}
if (mem == nullptr) { if (mem == nullptr) {
return false; return false;
} }