[U-Boot-Users] A bug fix to lib_ppc/board.c

Hi,
This is the original definition: #if defined(CFG_ENV_IS_EMBEDDED) #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN #elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ defined(CFG_ENV_IS_IN_NVRAM) #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) #else #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN #endif
While if your CFG_ENV_ADDR+CFG_ENV_SIZE is just equal with CFG_MONITOR_BASE and CFG_MALLOC_LEN is smaller than CFG_ENV_SIZE. Invalid pointer will be set to env_ptr in env_relocate () functions. Later operations to the environment will always to be performed to this invalid pointer address. And this might cause some abnormals in system level. In my testing board, the interrupts' enabling will trigger system hang-up under such abnormal situations.
The correct definition to fix this problem is: #if defined(CFG_ENV_IS_EMBEDDED) #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN #elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) <= CFG_MONITOR_BASE) || (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ defined(CFG_ENV_IS_IN_NVRAM) #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) #else #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN #endif
Regards, Tony
participants (1)
-
tony liu