drivers: gpio: esp32: check pin number range
As a complement of 7689abee34,
which fixed an issue where gpio number could errouneously be
set to a number greater than 32 in DTS, there is also another
situation where driver instance can be configured with a pin number
greater than 32.
This PR adds another check in GPIO driver to confirm
whether the PIN number is within valid bounds.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This commit is contained in:
parent
c50966ac17
commit
d29b98dbea
@ -91,7 +91,7 @@ static int gpio_esp32_config(const struct device *dev,
|
||||
{
|
||||
const struct gpio_esp32_config *const cfg = dev->config;
|
||||
struct gpio_esp32_data *data = dev->data;
|
||||
uint32_t io_pin = (uint32_t) pin + (cfg->gpio_port == 1 ? 32 : 0);
|
||||
uint32_t io_pin = (uint32_t) pin + ((cfg->gpio_port == 1 && pin < 32) ? 32 : 0);
|
||||
uint32_t key;
|
||||
int ret = 0;
|
||||
|
||||
@ -329,7 +329,7 @@ static int gpio_esp32_pin_interrupt_configure(const struct device *port,
|
||||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct gpio_esp32_config *const cfg = port->config;
|
||||
uint32_t io_pin = (uint32_t) pin + (cfg->gpio_port == 1 ? 32 : 0);
|
||||
uint32_t io_pin = (uint32_t) pin + ((cfg->gpio_port == 1 && pin < 32) ? 32 : 0);
|
||||
int intr_trig_mode = convert_int_type(mode, trig);
|
||||
uint32_t key;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user