[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+Px+wUc8+5HtkS8y4b9aw7m+wLS+zC1em6VKRNog1QKnJrZ=Q@mail.gmail.com>
Date: Thu, 18 Nov 2021 12:52:14 +0800
From: Tzung-Bi Shih <tzungbi@...gle.com>
To: Xin Ji <xji@...logixsemi.com>
Cc: a.hajda@...sung.com, narmstrong@...libre.com,
dan.carpenter@...cle.com, robert.foss@...aro.org,
Laurent.pinchart@...asonboard.com, jonas@...boo.se,
jernej.skrabec@...il.com, airlied@...ux.ie, daniel@...ll.ch,
sam@...nborg.org, pihsun@...omium.org, maxime@...no.tech,
drinkcat@...gle.com, hsinyi@...omium.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
bliang@...logixsemi.com, qwen@...logixsemi.com
Subject: Re: [PATCH] drm/bridge: anx7625: Check GPIO description to avoid crash
On Thu, Nov 18, 2021 at 11:11 AM Xin Ji <xji@...logixsemi.com> wrote:
> @@ -1098,9 +1098,18 @@ static void anx7625_init_gpio(struct anx7625_data *platform)
> /* Gpio for chip power enable */
> platform->pdata.gpio_p_on =
> devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
> + if (IS_ERR(platform->pdata.gpio_p_on)) {
> + DRM_DEV_DEBUG_DRIVER(dev, "no enable gpio found\n");
> + platform->pdata.gpio_p_on = NULL;
> + }
> +
> /* Gpio for chip reset */
> platform->pdata.gpio_reset =
> devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR(platform->pdata.gpio_reset)) {
> + DRM_DEV_DEBUG_DRIVER(dev, "no reset gpio found\n");
> + platform->pdata.gpio_p_on = NULL;
> + }
>
> if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) {
> platform->pdata.low_power_mode = 1;
devm_gpiod_get_optional() is possible to return NULL (see
https://elixir.bootlin.com/linux/v5.15.2/source/drivers/gpio/gpiolib-devres.c#L250).
Thus, we should use IS_ERR_OR_NULL for checking the return value.
The cases here would work fine except it will skip to print some
informative messages.
Acked-by: Tzung-Bi Shih <tzungbi@...gle.com>
Powered by blists - more mailing lists