mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Griffin <peter.griffin@linaro.org>
To: arnd@arndb.de, lee@kernel.org, thor.thayer@linux.intel.com
Cc: kernel-team@android.com, krzysztof.kozlowski@linaro.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, pankaj.dubey@samsung.com,
	tudor.ambarus@linaro.org, andre.draszik@linaro.org,
	saravanak@google.com, willmcvicker@google.com,
	Peter Griffin <peter.griffin@linaro.org>
Subject: [PATCH 3/3] mfd: altera-sysmgr: call of_node_put() only when of_parse_phandle() takes a ref
Date: Tue, 20 Feb 2024 11:50:12 +0000	[thread overview]
Message-ID: <20240220115012.471689-4-peter.griffin@linaro.org> (raw)
In-Reply-To: <20240220115012.471689-1-peter.griffin@linaro.org>

of_parse_phandle() returns a device_node with refcount incremented, which
the callee needs to call of_node_put() on when done. We should only call
of_node_put() when the property argument is provided though as otherwise
nothing has taken a reference on the node.

Fixes: f36e789a1f8d ("mfd: altera-sysmgr: Add SOCFPGA System Manager")
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
 drivers/mfd/altera-sysmgr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c
index 0e52bd2ebd74..fb5f988e61f3 100644
--- a/drivers/mfd/altera-sysmgr.c
+++ b/drivers/mfd/altera-sysmgr.c
@@ -109,7 +109,9 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np,
 
 	dev = driver_find_device_by_of_node(&altr_sysmgr_driver.driver,
 					    (void *)sysmgr_np);
-	of_node_put(sysmgr_np);
+	if (property)
+		of_node_put(sysmgr_np);
+
 	if (!dev)
 		return ERR_PTR(-EPROBE_DEFER);
 
-- 
2.44.0.rc0.258.g7320e95886-goog


  parent reply	other threads:[~2024-02-20 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 11:50 [PATCH 0/3] mfd syscon and altera-sysmgr cleanup Peter Griffin
2024-02-20 11:50 ` [PATCH 1/3] mfd: syscon: call of_node_put() only when of_parse_phandle() takes a ref Peter Griffin
2024-02-20 11:50 ` [PATCH 2/3] mfd: syscon: remove extern from function prototypes Peter Griffin
2024-02-20 11:50 ` Peter Griffin [this message]
2024-02-23 16:02 ` [PATCH 0/3] mfd syscon and altera-sysmgr cleanup 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=20240220115012.471689-4-peter.griffin@linaro.org \
    --to=peter.griffin@linaro.org \
    --cc=andre.draszik@linaro.org \
    --cc=arnd@arndb.de \
    --cc=kernel-team@android.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.dubey@samsung.com \
    --cc=saravanak@google.com \
    --cc=thor.thayer@linux.intel.com \
    --cc=tudor.ambarus@linaro.org \
    --cc=willmcvicker@google.com \
    /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

all inboxes | Powered by JetHome®