linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] media: platform: exynos4-is: Fix an OF node reference leak in fimc_md_is_isp_available
@ 2024-11-04 10:01 Joe Hattori
  2024-11-04 10:30 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Hattori @ 2024-11-04 10:01 UTC (permalink / raw)
  To: s.nawrocki, mchehab, krzk, alim.akhtar, kyungmin.park,
	andrzej.hajda
  Cc: linux-media, linux-samsung-soc, Joe Hattori

In fimc_md_is_isp_available(), of_get_child_by_name() is called to check
if FIMC-IS is available. Current code does not decrement the refcount of
the returned device node, which causes an OF node reference leak. Fix it
by calling of_node_put() at the end of the variable scope.

Fixes: e781bbe3fecf ("[media] exynos4-is: Add fimc-is subdevs registration")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
---
Changes in v2:
- Update the commit message.
- Change the name of the device node according to the naming convention.
---
 drivers/media/platform/samsung/exynos4-is/media-dev.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/samsung/exynos4-is/media-dev.h b/drivers/media/platform/samsung/exynos4-is/media-dev.h
index 786264cf79dc..a50e58ab7ef7 100644
--- a/drivers/media/platform/samsung/exynos4-is/media-dev.h
+++ b/drivers/media/platform/samsung/exynos4-is/media-dev.h
@@ -178,8 +178,9 @@ int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
 #ifdef CONFIG_OF
 static inline bool fimc_md_is_isp_available(struct device_node *node)
 {
-	node = of_get_child_by_name(node, FIMC_IS_OF_NODE_NAME);
-	return node ? of_device_is_available(node) : false;
+	struct device_node *child __free(device_node) =
+		of_get_child_by_name(node, FIMC_IS_OF_NODE_NAME);
+	return child ? of_device_is_available(child) : false;
 }
 #else
 #define fimc_md_is_isp_available(node) (false)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: platform: exynos4-is: Fix an OF node reference leak in fimc_md_is_isp_available
  2024-11-04 10:01 [PATCH v2] media: platform: exynos4-is: Fix an OF node reference leak in fimc_md_is_isp_available Joe Hattori
@ 2024-11-04 10:30 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2024-11-04 10:30 UTC (permalink / raw)
  To: Joe Hattori, s.nawrocki, mchehab, alim.akhtar, kyungmin.park,
	andrzej.hajda
  Cc: linux-media, linux-samsung-soc

On 04/11/2024 11:01, Joe Hattori wrote:
> In fimc_md_is_isp_available(), of_get_child_by_name() is called to check
> if FIMC-IS is available. Current code does not decrement the refcount of
> the returned device node, which causes an OF node reference leak. Fix it
> by calling of_node_put() at the end of the variable scope.
> 
> Fixes: e781bbe3fecf ("[media] exynos4-is: Add fimc-is subdevs registration")
> Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-04 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 10:01 [PATCH v2] media: platform: exynos4-is: Fix an OF node reference leak in fimc_md_is_isp_available Joe Hattori
2024-11-04 10:30 ` Krzysztof Kozlowski

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).