drm/bridge: anx7625: Check GPIO description to avoid crash

As GPIO probe function "devm_gpiod_get_optional()" may return error
code, driver should identify GPIO desc as NULL to avoid crash.

Acked-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Xin Ji <xji@analogixsemi.com>
Signed-off-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211119015804.3824027-1-xji@analogixsemi.com
Reviewed-by: Robert Foss <robert.foss@linaro.org>
This commit is contained in:
Xin Ji 2021-11-19 09:58:04 +08:00 committed by Robert Foss
parent 1726cee3d0
commit 7020449b8f
No known key found for this signature in database
GPG Key ID: 3EFD900F76D1D784

View File

@ -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_OR_NULL(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_OR_NULL(platform->pdata.gpio_reset)) {
DRM_DEV_DEBUG_DRIVER(dev, "no reset gpio found\n");
platform->pdata.gpio_reset = NULL;
}
if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) {
platform->pdata.low_power_mode = 1;