public inbox for linux-fbdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel@riscstar.com>
To: Chen Ni <nichen@iscas.ac.cn>
Cc: lee@kernel.org, danielt@kernel.org, jingoohan1@gmail.com,
	deller@gmx.de, linusw@kernel.org,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()
Date: Mon, 2 Feb 2026 09:54:57 +0000	[thread overview]
Message-ID: <aYB0cRwmiIb0vVnq@aspen.lan> (raw)
In-Reply-To: <20260202075410.155375-1-nichen@iscas.ac.cn>

On Mon, Feb 02, 2026 at 03:54:10PM +0800, Chen Ni wrote:
> The devm_gpiod_get_optional() function may return an ERR_PTR in case of
> genuine GPIO acquisition errors, not just NULL which indicates the
> legitimate absence of an optional GPIO.
>
> Add an IS_ERR() check after the call in sky81452_bl_parse_dt(). On
> error, return the error code to ensure proper failure handling rather
> than proceeding with invalid pointers.
>
> Fixes: e1915eec54a6 ("backlight: sky81452: Convert to GPIO descriptors")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/video/backlight/sky81452-backlight.c | 4 ++++
>  1 file changed, 4 insertions(+)

Thanks for the fix.

Small review comment below:

> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> index 2749231f0385..e3e5306fab84 100644
> --- a/drivers/video/backlight/sky81452-backlight.c
> +++ b/drivers/video/backlight/sky81452-backlight.c
> @@ -202,6 +202,10 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>  	pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode");
>  	pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift");
>  	pdata->gpiod_enable = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
> +	if (IS_ERR(pdata->gpiod_enable)) {
> +		dev_err(dev, "failed to get gpio\n");
> +		return ERR_CAST(pdata->gpiod_enable);
> +	}

Using dev_err_cast_probe() would make this change more compact and give
a better error message for the user.
>
>  	ret = of_property_count_u32_elems(np, "led-sources");
>  	if (ret < 0) {


Daniel.

  reply	other threads:[~2026-02-02  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02  7:54 [PATCH] backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt() Chen Ni
2026-02-02  9:54 ` Daniel Thompson [this message]
2026-02-03  2:16   ` [PATCH v2] " Chen Ni
2026-03-04 10:32     ` Daniel Thompson
2026-03-06 13:31     ` Linus Walleij
2026-03-06 14:21     ` (subset) " Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYB0cRwmiIb0vVnq@aspen.lan \
    --to=daniel@riscstar.com \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nichen@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox