drivers: gpio: Validate pin number before indexing array in mcux drivers
Validates the gpio pin number before using it to index into a memory-mapped register array. Otherwise, a user could send a high pin number and cause an out-of-bounds access. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
4394601524
commit
3c44137447
2 changed files with 10 additions and 0 deletions
|
@ -38,6 +38,11 @@ static int gpio_mcux_configure(struct device *dev,
|
|||
u32_t pcr = 0U;
|
||||
u8_t i;
|
||||
|
||||
/* Check for an invalid pin number */
|
||||
if (pin >= ARRAY_SIZE(port_base->PCR)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check for an invalid pin configuration */
|
||||
if ((flags & GPIO_INT) && (flags & GPIO_DIR_OUT)) {
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue