mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Krzysztof Kozlowski" <krzk@kernel.org>,
	"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
	"Chanwoo Choi" <cw00.choi@samsung.com>,
	"Peter Griffin" <peter.griffin@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Uwe Kleine-König (The Capable Hub)"
	<u.kleine-koenig@baylibre.com>,
	"Takashi Sakamoto" <o-takashi@sakamocchi.jp>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 01/12] clk: samsung: exynos5-subcmu: Detach power domain on add failure
Date: Fri, 27 Nov 2026 18:03:09 +0000	[thread overview]
Message-ID: <20261127180416.3277544-2-lee@kernel.org> (raw)
In-Reply-To: <20261127180416.3277544-1-lee@kernel.org>

exynos5_clk_register_subcmu() attaches &pdev->dev to its generic power
domain via of_genpd_add_device().  If platform_device_add() then fails,
it frees pdev via platform_device_put() without detaching it from the
power domain, leaving a dangling device pointer in the genpd device
list.

Record the return value of of_genpd_add_device() (keeping attachment
non-fatal when power domains are disabled) and call
pm_genpd_remove_device() before putting pdev if platform_device_add()
fails.

Fixes: b06a532bf1fa ("clk: samsung: Add Exynos5 sub-CMU clock driver")
Closes: https://sashiko.dev/#/bug/linux-0f461223-0d95-4e2c-b3d1-eac8e585e532
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/clk/samsung/clk-exynos5-subcmu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/samsung/clk-exynos5-subcmu.c b/drivers/clk/samsung/clk-exynos5-subcmu.c
index 373129847301..b0781e9f5640 100644
--- a/drivers/clk/samsung/clk-exynos5-subcmu.c
+++ b/drivers/clk/samsung/clk-exynos5-subcmu.c
@@ -137,7 +137,7 @@ static int __init exynos5_clk_register_subcmu(struct device *parent,
 {
 	struct of_phandle_args genpdspec = { .np = pd_node };
 	struct platform_device *pdev;
-	int ret;
+	int genpd_ret, ret;
 
 	pdev = platform_device_alloc("exynos5-subcmu", PLATFORM_DEVID_AUTO);
 	if (!pdev)
@@ -145,10 +145,13 @@ static int __init exynos5_clk_register_subcmu(struct device *parent,
 
 	pdev->dev.parent = parent;
 	platform_set_drvdata(pdev, (void *)info);
-	of_genpd_add_device(&genpdspec, &pdev->dev);
+	genpd_ret = of_genpd_add_device(&genpdspec, &pdev->dev);
 	ret = platform_device_add(pdev);
-	if (ret)
+	if (ret) {
+		if (!genpd_ret)
+			pm_genpd_remove_device(&pdev->dev);
 		platform_device_put(pdev);
+	}
 
 	return ret;
 }
-- 
2.56.1.839.g22a8290db9-goog


  reply	other threads:[~2026-11-27 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 18:03 [PATCH 00/12] clk: samsung: Fix power-domain, bus clock, and missing PLL sentinel bugs Lee Jones
2026-11-27 18:03 ` Lee Jones [this message]
2026-11-27 18:03 ` [PATCH 02/12] clk: samsung: exynos-arm64: Do not store ERR_PTR in data->clk Lee Jones
2026-11-27 18:03 ` [PATCH 03/12] clk: samsung: artpec8: Terminate PLL rate table with sentinel Lee Jones
2026-11-27 18:03 ` [PATCH 04/12] clk: samsung: artpec9: Terminate PLL rate tables with sentinels Lee Jones
2026-11-27 18:03 ` [PATCH 05/12] clk: samsung: exynos5250: Terminate PLL rate table with sentinel Lee Jones
2026-11-27 18:03 ` [PATCH 06/12] clk: samsung: exynos5260: Terminate PLL rate tables with sentinels Lee Jones
2026-11-27 18:03 ` [PATCH 07/12] clk: samsung: exynos5410: Terminate PLL rate table with sentinel Lee Jones
2026-11-27 18:03 ` [PATCH 08/12] clk: samsung: exynos7885: " Lee Jones
2026-11-27 18:03 ` [PATCH 09/12] clk: samsung: exynos850: " Lee Jones
2026-11-27 18:03 ` [PATCH 10/12] clk: samsung: exynos8895: Terminate PLL rate tables with sentinels Lee Jones
2026-11-27 18:03 ` [PATCH 11/12] clk: samsung: exynosautov920: Terminate PLL rate table with sentinel Lee Jones
2026-11-27 18:03 ` [PATCH 12/12] clk: samsung: fsd: Terminate PLL rate tables with sentinels 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=20261127180416.3277544-2-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=bhelgaas@google.com \
    --cc=bmasney+clk@redhat.com \
    --cc=cw00.choi@samsung.com \
    --cc=dakr@kernel.org \
    --cc=jbrunet+clk@baylibre.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=peter.griffin@linaro.org \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.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®