Skip to contentSkip to conversation

clk: samsung: Fix power-domain, bus clock, and missing PLL sentinel bugs

PATCH In review Lee Jones 2 participants 14 messages Nov 27 – Nov 28

Subsystems (6)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

cover clk: samsung: Fix power-domain, bus clock, and missing PLL sentinel bugs

The first two issues were reported by Sashiko; the remaining ten patches append missing zero sentinels to all remaining Samsung PLL rate tables, following Krzysztof Kozlowski's request on the Exynos5420 fix.

This series is based on krzk/linux next/clk.

Cc "Dávid Virág" <[email protected]>
Cc "Uwe Kleine-König (The Capable Hub)" <[email protected]>
Cc Ajay Kumar <[email protected]>
Cc Alexey Klimov <[email protected]>
Cc Alim Akhtar <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Brian Masney <[email protected]>
Cc Chanwoo Choi <[email protected]>
Cc Danilo Krummrich <[email protected]>
Cc GyoungBo Min <[email protected]>
Cc Hakyeong Kim <[email protected]>
Cc Ivaylo Ivanov <[email protected]>
Cc Jayati Sahu <[email protected]>
Cc Jerome Brunet <[email protected]>
Cc Jesper Nilsson <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Lars Persson <[email protected]>
Cc Marek Szyprowski <[email protected]>
Cc Pankaj Dubey <[email protected]>
Cc Peter Griffin <[email protected]>
Cc Raghav Sharma <[email protected]>
Cc Rahul Sharma <[email protected]>
Cc Ravi Patel <[email protected]>
Cc Sachin Kamat <[email protected]>
Cc Sam Protsenko <[email protected]>
Cc Sathyakam M <[email protected]>
Cc SeonGu Kang <[email protected]>
Cc Shin Son <[email protected]>
Cc Smitha T Murthy <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Sunyeal Hong <[email protected]>
Cc Sylwester Nawrocki <[email protected]>
Cc Takashi Sakamoto <[email protected]>
Cc Tarek Dakhran <[email protected]>
Cc Thomas Abraham <[email protected]>
Cc Tomasz Figa <[email protected]>
Cc Varada Pavani <[email protected]>

Lee Jones (12):
clk: samsung: exynos5-subcmu: Detach power domain on add failure
clk: samsung: exynos-arm64: Do not store ERR_PTR in data->clk
clk: samsung: artpec8: Terminate PLL rate table with sentinel
clk: samsung: artpec9: Terminate PLL rate tables with sentinels
clk: samsung: exynos5250: Terminate PLL rate table with sentinel
clk: samsung: exynos5260: Terminate PLL rate tables with sentinels
clk: samsung: exynos5410: Terminate PLL rate table with sentinel
clk: samsung: exynos7885: Terminate PLL rate table with sentinel
clk: samsung: exynos850: Terminate PLL rate table with sentinel
clk: samsung: exynos8895: Terminate PLL rate tables with sentinels
clk: samsung: exynosautov920: Terminate PLL rate table with sentinel
clk: samsung: fsd: Terminate PLL rate tables with sentinels

 drivers/clk/samsung/clk-artpec8.c        |  1 +
 drivers/clk/samsung/clk-artpec9.c        |  3 +++
 drivers/clk/samsung/clk-exynos-arm64.c   | 26 ++++++++++++++++--------
 drivers/clk/samsung/clk-exynos5-subcmu.c |  9 +++++---
 drivers/clk/samsung/clk-exynos5250.c     |  1 +
 drivers/clk/samsung/clk-exynos5260.c     |  2 ++
 drivers/clk/samsung/clk-exynos5410.c     |  1 +
 drivers/clk/samsung/clk-exynos7885.c     |  1 +
 drivers/clk/samsung/clk-exynos850.c      |  1 +
 drivers/clk/samsung/clk-exynos8895.c     |  5 +++++
 drivers/clk/samsung/clk-exynosautov920.c |  1 +
 drivers/clk/samsung/clk-fsd.c            |  6 ++++++
 12 files changed, 45 insertions(+), 12 deletions(-)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#1 lore raw

PATCH 1/12 clk: samsung: exynos5-subcmu: Detach power domain on add failure

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")
---
 drivers/clk/samsung/clk-exynos5-subcmu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/clk/samsung/clk-exynos5-subcmu.c +6 -3
index 373129847301..b0781e9f5640 100644
@@ -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;
 }
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#2 lore raw

PATCH 2/12 clk: samsung: exynos-arm64: Do not store ERR_PTR in data->clk

In reply to Lee Jones

exynos_arm64_enable_bus_clk() assigns parent_clk to data->clk before checking IS_ERR(parent_clk) or enabling the clock. Because exynos_arm64_register_cmu_pm() logs the failure and continues registering PM callbacks, exynos_arm64_cmu_suspend() and exynos_arm64_cmu_resume() later pass the error pointer to clk_disable_unprepare() and clk_prepare_enable(), causing a crash.

Only store parent_clk in data->clk after IS_ERR() and clk_prepare_enable() succeed, and release the clock reference on enable failure.

Fixes f05dc2024316 ("clk: samsung: exynos5433: Extract PM support to common ARM64 layer")
---
 drivers/clk/samsung/clk-exynos-arm64.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
drivers/clk/samsung/clk-exynos-arm64.c +17 -9
index 35d4de233cc1..360bd5d8421d 100644
@@ -149,25 +149,33 @@ static int __init exynos_arm64_enable_bus_clk(struct device *dev,
 		struct device_node *np, const struct samsung_cmu_info *cmu)
 {
 	struct clk *parent_clk;
+	int ret;
 
 	if (!cmu->clk_name)
 		return 0;
 
-	if (dev) {
-		struct exynos_arm64_cmu_data *data;
-
+	if (dev)
 		parent_clk = clk_get(dev, cmu->clk_name);
-		data = dev_get_drvdata(dev);
-		if (data)
-			data->clk = parent_clk;
-	} else {
+	else
 		parent_clk = of_clk_get_by_name(np, cmu->clk_name);
-	}
 
 	if (IS_ERR(parent_clk))
 		return PTR_ERR(parent_clk);
 
-	return clk_prepare_enable(parent_clk);
+	ret = clk_prepare_enable(parent_clk);
+	if (ret) {
+		clk_put(parent_clk);
+		return ret;
+	}
+
+	if (dev) {
+		struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev);
+
+		if (data)
+			data->clk = parent_clk;
+	}
+
+	return 0;
 }
 
 static int __init exynos_arm64_cmu_prepare_pm(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#3 lore raw

PATCH 3/12 clk: samsung: artpec8: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, artpec8_pll_audio_rates omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to artpec8_pll_audio_rates.

Fixes bd5336e3f704 ("clk: samsung: artpec-8: Add initial clock support for ARTPEC-8 SoC")
---
 drivers/clk/samsung/clk-artpec8.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-artpec8.c +1 -0
index 0ea7c8b58674..fd35643be2e3 100644
@@ -173,6 +173,7 @@ static const struct samsung_pll_rate_table artpec8_pll_audio_rates[] __initconst
 	PLL_36XX_RATE(25 * MHZ, 100000000U, 32, 2, 2, 0),
 	PLL_36XX_RATE(25 * MHZ,  98303985U, 47, 3, 2, 12184),
 	PLL_36XX_RATE(25 * MHZ,  49151992U, 47, 3, 3, 12184),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cmu_cmu_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#4 lore raw

PATCH 4/12 clk: samsung: artpec9: Terminate PLL rate tables with sentinels

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, artpec9_pll_audio_rates, artpec9_pll_cpucl_rates, and artpec9_pll_fsys1_rates all omit a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to each of the 3 PLL rate tables.

Fixes 85cc5be65b82 ("clk: samsung: artpec-9: Add initial clock support for ARTPEC-9 SoC")
---
 drivers/clk/samsung/clk-artpec9.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/samsung/clk-artpec9.c +3 -0
index 2eaf8117638c..aee5a9283de4 100644
@@ -176,6 +176,7 @@ static const unsigned long cmu_cmu_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table artpec9_pll_audio_rates[] __initconst = {
 	PLL_A9FRACO_RATE(25 * MHZ, 589824000U, 94, 1, 3, 6238440),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cmu_cmu_pll_clks[] __initconst = {
@@ -490,6 +491,7 @@ static const struct samsung_pll_rate_table artpec9_pll_cpucl_rates[] __initconst
 	PLL_35XX_RATE(25 * MHZ, 1400000000U, 56, 1, 0),
 	PLL_35XX_RATE(25 * MHZ, 1100000000U, 44, 1, 0),
 	PLL_35XX_RATE(25 * MHZ,  850000000U, 34, 1, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cmu_cpucl_pll_clks[] __initconst = {
@@ -815,6 +817,7 @@ static const unsigned long cmu_fsys1_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table artpec9_pll_fsys1_rates[] __initconst = {
 	PLL_35XX_RATE(25 * MHZ, 2000000000U, 80, 1, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cmu_fsys1_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#5 lore raw

PATCH 5/12 clk: samsung: exynos5250: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, apll_24mhz_tbl omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to apll_24mhz_tbl.

Fixes f521ac8b390c ("clk: exynos5250: register APLL rate table")
---
 drivers/clk/samsung/clk-exynos5250.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-exynos5250.c +1 -0
index 802300c945a9..bce5b03ecd2f 100644
@@ -730,6 +730,7 @@ static const struct samsung_pll_rate_table apll_24mhz_tbl[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 400000000, 100, 3, 1),
 	PLL_35XX_RATE(24 * MHZ, 300000000, 200, 4, 2),
 	PLL_35XX_RATE(24 * MHZ, 200000000, 100, 3, 2),
+	{ /* sentinel */ }
 };
 
 static struct samsung_pll_clock exynos5250_plls[nr_plls] __initdata = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#6 lore raw

PATCH 6/12 clk: samsung: exynos5260: Terminate PLL rate tables with sentinels

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, pll2550_24mhz_tbl and pll2650_24mhz_tbl both omit a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to both PLL rate tables.

Fixes d39e55e06371 ("clk/exynos5260: add clock file for exynos5260")
---
 drivers/clk/samsung/clk-exynos5260.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/samsung/clk-exynos5260.c +2 -0
index 0a5959823370..8417321c1202 100644
@@ -59,6 +59,7 @@ static const struct samsung_pll_rate_table pll2550_24mhz_tbl[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 266000000, 266, 3, 3),
 	PLL_35XX_RATE(24 * MHZ, 200000000, 200, 3, 3),
 	PLL_35XX_RATE(24 * MHZ, 160000000, 160, 3, 3),
+	{ /* sentinel */ }
 };
 
 /*
@@ -83,6 +84,7 @@ static const struct samsung_pll_rate_table pll2650_24mhz_tbl[] __initconst = {
 	PLL_36XX_RATE(24 * MHZ, 133000000, 266, 3, 4, 0),
 	PLL_36XX_RATE(24 * MHZ, 100000000, 200, 3, 4, 0),
 	PLL_36XX_RATE(24 * MHZ, 66000000, 176, 2, 5, 0),
+	{ /* sentinel */ }
 };
 
 /* CMU_AUD */
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#7 lore raw

PATCH 7/12 clk: samsung: exynos5410: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, exynos5410_pll2550x_24mhz_tbl omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to exynos5410_pll2550x_24mhz_tbl.

Fixes be95d2c7d918 ("clk: samsung: Add support for EPLL on exynos5410")
---
 drivers/clk/samsung/clk-exynos5410.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-exynos5410.c +1 -0
index baa9988c7bb7..0036544bd77d 100644
@@ -235,6 +235,7 @@ static const struct samsung_pll_rate_table exynos5410_pll2550x_24mhz_tbl[] __ini
 	PLL_36XX_RATE(24 * MHZ, 133000000U, 266, 3, 4, 0),
 	PLL_36XX_RATE(24 * MHZ, 100000000U, 200, 3, 4, 0),
 	PLL_36XX_RATE(24 * MHZ, 66000000U,  176, 2, 5, 0),
+	{ /* sentinel */ }
 };
 
 static struct samsung_pll_clock exynos5410_plls[nr_plls] __initdata = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#8 lore raw

PATCH 8/12 clk: samsung: exynos7885: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, pll_usb_rate_table omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to pll_usb_rate_table.

Fixes 011a9de99793 ("clk: samsung: exynos7885: Add USB related clocks to CMU_FSYS")
---
 drivers/clk/samsung/clk-exynos7885.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-exynos7885.c +1 -0
index 17c2a4fc1a55..6bde2437b0ff 100644
@@ -729,6 +729,7 @@ static const unsigned long fsys_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table pll_usb_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 50000000U, 400, 13, 4),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock fsys_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#9 lore raw

PATCH 9/12 clk: samsung: exynos850: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, cpu_pll_rates omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to cpu_pll_rates.

Fixes dedf87341ad6 ("clk: samsung: exynos850: Add CMU_CPUCL0 and CMU_CPUCL1")
---
 drivers/clk/samsung/clk-exynos850.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-exynos850.c +1 -0
index ebcdde93bd46..9ac311161a3e 100644
@@ -1180,6 +1180,7 @@ static const struct samsung_pll_rate_table cpu_pll_rates[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 247000000U,  114, 3, 2),
 	PLL_35XX_RATE(26 * MHZ, 182000000U,  168, 3, 3),
 	PLL_35XX_RATE(26 * MHZ, 130000000U,  120, 3, 3),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cpucl0_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#10 lore raw

PATCH 10/12 clk: samsung: exynos8895: Terminate PLL rate tables with sentinels

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, pll_shared0_rate_table, pll_shared1_rate_table, pll_shared2_rate_table, pll_shared3_rate_table, and pll_shared4_rate_table all omit a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to each of the 5 PLL rate tables.

Fixes 9174fac3b302 ("clk: samsung: Introduce Exynos8895 clock driver")
---
 drivers/clk/samsung/clk-exynos8895.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/samsung/clk-exynos8895.c +5 -0
index 259481c4276e..daf337f47e4f 100644
@@ -478,22 +478,27 @@ static const unsigned long top_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table pll_shared0_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 2132000000U, 328, 4, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared1_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 1865500000U, 287, 4, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared2_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 800000000U, 400, 13, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared3_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 630000000U, 315, 13, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared4_rate_table[] __initconst = {
 	PLL_35XX_RATE(26 * MHZ, 667333333U, 154, 6, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock top_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#12 lore raw

PATCH 11/12 clk: samsung: exynosautov920: Terminate PLL rate table with sentinel

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, cpu_pll_rates omits a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to cpu_pll_rates.

Fixes 59636ec89c2c ("clk: samsung: exynosautov920: add cpucl0 clock support")
---
 drivers/clk/samsung/clk-exynosautov920.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/samsung/clk-exynosautov920.c +1 -0
index a938f3cc7b57..7c4e9ab25624 100644
@@ -1077,6 +1077,7 @@ static const struct samsung_pll_rate_table cpu_pll_rates[] __initconst = {
 	PLL_35XX_RATE(38400000U, 1152000000U, 120, 4, 0),
 	PLL_35XX_RATE(38400000U, 576000000U, 120, 4, 1),
 	PLL_35XX_RATE(38400000U, 288000000U, 120, 4, 2),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cpucl0_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#13 lore raw

PATCH 12/12 clk: samsung: fsd: Terminate PLL rate tables with sentinels

In reply to Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, pll_shared0_rate_table, pll_shared1_rate_table, pll_shared2_rate_table, pll_shared3_rate_table, pll_mfc_rate_table, and pll_cam_csi_rate_table all omit a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to each of the 6 PLL rate tables.

Fixes 4f346005aaed ("clk: samsung: fsd: Add initial clock support")
Fixes 75c50afaa0d9 ("clk: samsung: fsd: Add cmu_mfc block clock information")
Fixes b826c3e4de1a ("clk: samsung: fsd: Add cam_csi block clock information")
---
 drivers/clk/samsung/clk-fsd.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/clk/samsung/clk-fsd.c +6 -0
index 0a0bf1d62a04..ded7bfa97234 100644
@@ -155,18 +155,22 @@ static const unsigned long cmu_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table pll_shared0_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 2000000000U, 250, 3, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared1_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 2400000000U, 200, 2, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared2_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 2400000000U, 200, 2, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_rate_table pll_shared3_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 1800000000U, 150, 2, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cmu_pll_clks[] __initconst = {
@@ -1482,6 +1486,7 @@ static const unsigned long mfc_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table pll_mfc_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 666000000U, 111, 4, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock mfc_pll_clks[] __initconst = {
@@ -1642,6 +1647,7 @@ static const unsigned long cam_csi_clk_regs[] __initconst = {
 
 static const struct samsung_pll_rate_table pll_cam_csi_rate_table[] __initconst = {
 	PLL_35XX_RATE(24 * MHZ, 1066000000U, 533, 12, 0),
+	{ /* sentinel */ }
 };
 
 static const struct samsung_pll_clock cam_csi_pll_clks[] __initconst = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
Reviewed-by on v1 10/12
#11 lore raw

Re: [PATCH 10/12] clk: samsung: exynos8895: Terminate PLL rate tables with sentinels

In reply to Lee Jones
Quoted 11 lines · Lee Jones

_samsung_clk_register_pll() sizes each PLL rate table by scanning until it encounters an entry with .rate == 0, then copies the counted entries into pll->rate_table. However, pll_shared0_rate_table, pll_shared1_rate_table, pll_shared2_rate_table, pll_shared3_rate_table, and pll_shared4_rate_table all omit a terminating zero sentinel, causing out-of-bounds reads into adjacent read-only data and populating pll->rate_table with bogus entries.

Append a sentinel entry to each of the 5 PLL rate tables.

Fixes 9174fac3b302 ("clk: samsung: Introduce Exynos8895 clock driver")

Looks good to me. Thanks, nice catch!

Quoted 11 lines
---
  drivers/clk/samsung/clk-exynos8895.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/clk/samsung/clk-exynos8895.c +0 -0
index 259481c4276e..daf337f47e4f 100644

drivers/clk/samsung/clk-exynos8895.c static const unsigned long top_clk_regs[] __initconst = { · line 483

Quoted 6 lines
drivers/clk/samsung/clk-exynos8895.c +1 -0
@@ -478,22 +478,27 @@ static const unsigned long top_clk_regs[] __initconst = {
 
  static const struct samsung_pll_rate_table pll_shared0_rate_table[] __initconst = {
  	PLL_35XX_RATE(26 * MHZ, 2132000000U, 328, 4, 0),
+	{ /* sentinel */ }
  };
 

...

Best regards,
Ivaylo