kernel: fatal: check for esf validity when inspecting nested IRQ

For architectures that support detection of nested interrupts,
we need to check the validity of the exception stack frame,
before we can supply it as a pointer to the function that
evaluates whether we are in a nested interrupt context. This
commits adds the required esf pointer checks in z_fatal_error().

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2020-03-09 20:36:21 +01:00 committed by Johan Hedberg
parent 0773fd5963
commit 49fb5d0812
1 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
* See #17656
*/
#if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION)
if (arch_is_in_nested_exception(esf)) {
if ((esf != NULL) && arch_is_in_nested_exception(esf)) {
LOG_ERR("Fault during interrupt handling\n");
}
#endif
@ -140,7 +140,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
"Attempted to recover from a kernel panic condition");
/* FIXME: #17656 */
#if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION)
if (arch_is_in_nested_exception(esf)) {
if ((esf != NULL) && arch_is_in_nested_exception(esf)) {
#if defined(CONFIG_STACK_SENTINEL)
if (reason != K_ERR_STACK_CHK_FAIL) {
__ASSERT(0,
@ -152,7 +152,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
} else {
/* Test mode */
#if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION)
if (arch_is_in_nested_exception(esf)) {
if ((esf != NULL) && arch_is_in_nested_exception(esf)) {
/* Abort the thread only on STACK Sentinel check fail. */
#if defined(CONFIG_STACK_SENTINEL)
if (reason != K_ERR_STACK_CHK_FAIL) {