public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	 Patrick Rudolph <patrick.rudolph@9elements.com>,
	 Naresh Solanki <Naresh.Solanki@9elements.com>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH 1/2] leds: max5970: fix unreleased fwnode_handle in probe function
Date: Sat, 19 Oct 2024 21:36:43 +0200	[thread overview]
Message-ID: <20241019-max5970-of_node_put-v1-1-e6ce4af4119b@gmail.com> (raw)
In-Reply-To: <20241019-max5970-of_node_put-v1-0-e6ce4af4119b@gmail.com>

An object initialized via device_get_named_child_node() requires calls
to fwnode_handle_put() when it is no longer required to avoid leaking
memory.

Add the missing calls to fwnode_handle_put() in the different paths
(error paths and normal exit).

Cc: stable@vger.kernel.org
Fixes: 736214b4b02a ("leds: max5970: Add support for max5970")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/leds/leds-max5970.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c
index 56a584311581..c021330e0ae7 100644
--- a/drivers/leds/leds-max5970.c
+++ b/drivers/leds/leds-max5970.c
@@ -72,6 +72,7 @@ static int max5970_led_probe(struct platform_device *pdev)
 
 		ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
 		if (!ddata) {
+			fwnode_handle_put(led_node);
 			fwnode_handle_put(child);
 			return -ENOMEM;
 		}
@@ -89,11 +90,14 @@ static int max5970_led_probe(struct platform_device *pdev)
 
 		ret = devm_led_classdev_register(dev, &ddata->cdev);
 		if (ret < 0) {
+			fwnode_handle_put(led_node);
 			fwnode_handle_put(child);
 			return dev_err_probe(dev, ret, "Failed to initialize LED %u\n", reg);
 		}
 	}
 
+	fwnode_handle_put(led_node);
+
 	return ret;
 }
 

-- 
2.43.0


  reply	other threads:[~2024-10-19 19:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19 19:36 [PATCH 0/2] leds: max5970: fix unreleased fwnode_handle in probe function Javier Carrasco
2024-10-19 19:36 ` Javier Carrasco [this message]
2024-10-31 16:12   ` (subset) [PATCH 1/2] " Lee Jones
2024-10-31 16:14     ` Lee Jones
2024-10-19 19:36 ` [PATCH 2/2] leds: max5970: use cleanup facility for fwnode_handle led_node Javier Carrasco
2024-10-31 16:14   ` 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=20241019-max5970-of_node_put-v1-1-e6ce4af4119b@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=Naresh.Solanki@9elements.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=patrick.rudolph@9elements.com \
    --cc=pavel@ucw.cz \
    --cc=stable@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