Skip to content

Commit

Permalink
[review] drivers: stm32_gpio: check secure state of pinctrl states
Browse files Browse the repository at this point in the history
Check each pins can be accessed when applying a pinctrl state.

Return TEE_ERROR_SECURITY instead of TEE_ERROR_GENERIC when failing
to apply a pinctrl state due to the pin configuration access rights.

Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Nov 12, 2024
1 parent f3f52c1 commit 0feb9c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/drivers/stm32_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 0feb9c2

Please sign in to comment.