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 95e5abf commit c3886b1
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 @@ -1291,6 +1291,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 @@ -1309,7 +1316,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 c3886b1

Please sign in to comment.