aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ford <[email protected]>2019-10-06 11:33:11 -0500
committerGreg Kroah-Hartman <[email protected]>2019-10-07 13:21:54 +0200
commit37e3ab00e4734acc15d96b2926aab55c894f4d9c (patch)
tree65ba1c11ae2f099d73b6d193731bea47167fcc41
parent5df884d4b8a5bf2ec5e0b92394e40112d0a0a520 (diff)
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]>
-rw-r--r--drivers/tty/serial/serial_mctrl_gpio.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
index d9074303c88e..fb4781292d40 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.c
+++ b/drivers/tty/serial/serial_mctrl_gpio.c
@@ -66,6 +66,9 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set);
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
enum mctrl_gpio_idx gidx)
{
+ if (gpios == NULL)
+ return NULL;
+
return gpios->gpio[gidx];
}
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);