Skip to content

Commit 37e3ab0

Browse files
aford173gregkh
authored andcommitted
serial: mctrl_gpio: Check for NULL pointer
When using mctrl_gpio_to_gpiod, it dereferences gpios into a single requested GPIO. This dereferencing can break if gpios is NULL, so this patch adds a NULL check before dereferencing it. If gpios is NULL, this function will also return NULL. Signed-off-by: Adam Ford <[email protected]> Reviewed-by: Yegor Yefremov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5df884d commit 37e3ab0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/tty/serial/serial_mctrl_gpio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set);
6666
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
6767
enum mctrl_gpio_idx gidx)
6868
{
69+
if (gpios == NULL)
70+
return NULL;
71+
6972
return gpios->gpio[gidx];
7073
}
7174
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);

0 commit comments

Comments
 (0)