[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191006163314.23191-1-aford173@gmail.com>
Date: Sun, 6 Oct 2019 11:33:11 -0500
From: Adam Ford <aford173@...il.com>
To: linux-serial@...r.kernel.org
Cc: Adam Ford <aford173@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Vignesh R <vigneshr@...com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Douglas Anderson <dianders@...omium.org>,
Tony Lindgren <tony@...mide.com>,
Yegor Yefremov <yegorslists@...glemail.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH V2 1/2] 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 <aford173@...il.com>
---
V2: This patch is new to the V2 of this series, so patch 2/2 can
work without risking a NULL dereference
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);
--
2.17.1
Powered by blists - more mailing lists