linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rklein@nvidia.com (Rhyland Klein)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] power_supply: Add of_node_put to fix refcount
Date: Mon, 10 Jun 2013 17:26:39 -0400	[thread overview]
Message-ID: <1370899602-22123-2-git-send-email-rklein@nvidia.com> (raw)
In-Reply-To: <1370899602-22123-1-git-send-email-rklein@nvidia.com>

of_parse_phandle increments the refcount for a dt node before returning
it. Add of_node_put where needed to properly decrement the refcount
when we are done using a given node.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
---
 drivers/power/power_supply_core.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 1c517c3..3b2d5df 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -109,8 +109,10 @@ static int __power_supply_populate_supplied_from(struct device *dev,
 				psy->name, epsy->name);
 			psy->supplied_from[i-1] = (char *)epsy->name;
 			psy->num_supplies++;
+			of_node_put(np);
 			break;
 		}
+		of_node_put(np);
 	} while (np);
 
 	return 0;
@@ -193,8 +195,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
 		ret = power_supply_find_supply_from_node(np);
 		if (ret) {
 			dev_dbg(psy->dev, "Failed to find supply, defer!\n");
+			of_node_put(np);
 			return -EPROBE_DEFER;
 		}
+		of_node_put(np);
 	} while (np);
 
 	/* All supplies found, allocate char ** array for filling */
-- 
1.7.9.5

  reply	other threads:[~2013-06-10 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10 21:26 [PATCH 0/4] Fix and start using supplied_from logic Rhyland Klein
2013-06-10 21:26 ` Rhyland Klein [this message]
2013-06-29  1:22   ` [PATCH 1/4] power_supply: Add of_node_put to fix refcount Anton Vorontsov
2013-07-01 16:13     ` Rhyland Klein
2013-06-10 21:26 ` [PATCH 2/4] power: sbs-battery: Add dt to power_supply struct Rhyland Klein
2013-06-10 21:26 ` [PATCH 3/4] power: tps65090-charger: Add dt node to power_supply Rhyland Klein
2013-06-10 21:26 ` [PATCH 4/4] arm: tegra: Add power-supplies link between battery and charger Rhyland Klein
2013-06-12 17:44   ` Stephen Warren
2013-06-12 17:46     ` Rhyland Klein
2013-06-12 21:32   ` Stephen Warren

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=1370899602-22123-2-git-send-email-rklein@nvidia.com \
    --to=rklein@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).