diff options
author | Adam Ford <aford173@gmail.com> | 2019-10-06 11:33:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-06 13:08:17 +0100 |
commit | 07d7a3e98c1048f2bfdbd250e8f87944b48f513e (patch) | |
tree | ffdef7caaf52007a8047115561f6d9ec07a5d921 | |
parent | 531da3831c0272e5a09b7c20929a2b01978f868d (diff) | |
download | linux-stable-07d7a3e98c1048f2bfdbd250e8f87944b48f513e.tar.gz linux-stable-07d7a3e98c1048f2bfdbd250e8f87944b48f513e.tar.bz2 linux-stable-07d7a3e98c1048f2bfdbd250e8f87944b48f513e.zip |
serial: mctrl_gpio: Check for NULL pointer
[ Upstream commit 37e3ab00e4734acc15d96b2926aab55c894f4d9c ]
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 <aford173@gmail.com>
Reviewed-by: Yegor Yefremov <yegorslists@googlemail.com>
Link: https://lore.kernel.org/r/20191006163314.23191-1-aford173@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/tty/serial/serial_mctrl_gpio.c | 3 |
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 2b400189be91..54c43e02e375 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c @@ -61,6 +61,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); |