diff --git a/core/drivers/stm32_gpio.c b/core/drivers/stm32_gpio.c index 7c347a3e2ee..d815a43ba3a 100644 --- a/core/drivers/stm32_gpio.c +++ b/core/drivers/stm32_gpio.c @@ -1296,6 +1296,13 @@ static TEE_Result stm32_pinctrl_conf_apply(struct pinconf *conf) for (n = 0; n < pin_count; n++) { struct stm32_gpio_bank *bank = stm32_gpio_get_bank(p[n].bank); + if (!pin_is_accessible(bank, p[n].pin)) { + EMSG("Apply pinctrl for pin %c%u that cannot be accessed", + p[n].bank + 'A', p[n].pin); + error = true; + continue; + } + if (p[n].cfg.nsec == !pin_is_secure(bank, p[n].pin)) continue; @@ -1314,7 +1321,7 @@ static TEE_Result stm32_pinctrl_conf_apply(struct pinconf *conf) } if (error) - return TEE_ERROR_GENERIC; + return TEE_ERROR_SECURITY; for (n = 0; n < pin_count; n++) set_gpio_cfg(p[n].bank, p[n].pin, &p[n].cfg);