[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGm1_kvC7745jhRawSinTtMr4LSbTFaE7-pnoar=tpjLD2nDcQ@mail.gmail.com>
Date: Sun, 6 Oct 2019 20:11:14 +0200
From: Yegor Yefremov <yegorslists@...glemail.com>
To: Adam Ford <aford173@...il.com>
Cc: linux-serial@...r.kernel.org,
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>,
kernel list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2 1/2] serial: mctrl_gpio: Check for NULL pointer
On Sun, Oct 6, 2019 at 6:33 PM Adam Ford <aford173@...il.com> wrote:
>
> 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>
Reviewed-by: Yegor Yefremov <yegorslists@...glemail.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