Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Henry Martin <bsdhenrymartin@gmail.com>,
	linux-fbdev@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	Daniel Thompson <danielt@kernel.org>,
	Daniel Thompson <daniel@riscstar.com>,
	Helge Deller <deller@gmx.de>, Jingoo Han <jingoohan1@gmail.com>,
	Lee Jones <lee@kernel.org>
Subject: Re: [PATCH] backlight: qcom-wled: Add NULL check in the wled_configure
Date: Mon, 31 Mar 2025 13:50:35 +0200	[thread overview]
Message-ID: <1ec61529-09f2-44d8-9324-b94da82158c4@web.de> (raw)
In-Reply-To: <20250331091245.6668-1-bsdhenrymartin@gmail.com>

> When devm_kasprintf() fails, it returns a NULL pointer. However, this return value is not properly checked in the function wled_configure.
>
> A NULL check should be added after the devm_kasprintf call to prevent potential NULL pointer dereference error.

* Please adhere to word wrapping preferences around 75 characters per text line.

* How do you think about to choose the imperative mood for an improved change description?
  https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94> +++ b/drivers/video/backlight/qcom-wled.c
> @@ -1406,8 +1406,14 @@ static int wled_configure(struct wled *wled)
>  	wled->ctrl_addr = be32_to_cpu(*prop_addr);
>
>  	rc = of_property_read_string(dev->of_node, "label", &wled->name);
> -	if (rc)
> +	if (rc) {
>  		wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
> +		if (!wled->name) {
> +			dev_err(dev, "Failed to allocate memory for wled name\n");
> +			return -ENOMEM;
> +		}
> +	}
…

An extra error messages for a failed memory allocation may occasionally be omitted.

Regards,
Markus

      parent reply	other threads:[~2025-03-31 11:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31  9:12 [PATCH] backlight: qcom-wled: Add NULL check in the wled_configure Henry Martin
2025-03-31 11:11 ` Daniel Thompson
2025-03-31 11:50 ` Markus Elfring [this message]

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=1ec61529-09f2-44d8-9324-b94da82158c4@web.de \
    --to=markus.elfring@web.de \
    --cc=bsdhenrymartin@gmail.com \
    --cc=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=linux-arm-msm@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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