Skip to contentSkip to conversation

iio: adc: ade9000: fix NULL pointer dereference in clkout registration

PATCH Applied Linmao Li 3 participants 5 messages Aug 26 – Sep 23

Subsystems (4)
lore
Share & tools
lore

Linmao Li

author
#0 lore raw

PATCH v2 1/1 iio: adc: ade9000: fix NULL pointer dereference in clkout registration

ade9000_setup_clkout() passes NULL as the register address when registering a divider clock. During clock registration, the common clock framework calls clk_divider_recalc_rate(), which dereferences the address through readl(). As a result, probing an ADE9000 configured as a clock provider with an external input clock crashes.

CLKOUT passes CLKIN through without changing its rate. Register it as a 1:1 fixed-factor clock, which does not require register access.

This change does not affect the configuration using the internal clock, for which the driver does not register a clock provider.

Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

---
Changes in v2:
- Clarify that the configuration using the internal clock is unaffected.

 drivers/iio/adc/ade9000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +3 -2
index e57e24b6acdf7..4e96cc37fbedf 100644
@@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)
 		return 0;
 
 	/* CLKOUT passes through CLKIN with divider of 1 */
-	clkout_hw = devm_clk_hw_register_divider(dev, "clkout", __clk_get_name(st->clkin),
-						 CLK_SET_RATE_PARENT, NULL, 0, 1, 0, NULL);
+	clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout",
+						      __clk_get_name(st->clkin),
+						      CLK_SET_RATE_PARENT, 1, 1);
 	if (IS_ERR(clkout_hw))
 		return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to register clkout");
 

base-commit: 6b9f23b5460818aaf199dda90210d5fc08d66c8f

Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · On Wed, 26 Aug 2026 16:31:56 +0800 Linmao Li <[email protected]> wrote:

ade9000_setup_clkout() passes NULL as the register address when registering a divider clock. During clock registration, the common clock framework calls clk_divider_recalc_rate(), which dereferences the address through readl(). As a result, probing an ADE9000 configured as a clock provider with an external input clock crashes.

CLKOUT passes CLKIN through without changing its rate. Register it as a 1:1 fixed-factor clock, which does not require register access.

Quoted 6 lines

This change does not affect the configuration using the internal clock, for which the driver does not register a clock provider.

Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

Looking for a tag from Antoniu for this one.

Quoted 25 lines

---
Changes in v2:
- Clarify that the configuration using the internal clock is unaffected.

 drivers/iio/adc/ade9000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +3 -2
index e57e24b6acdf7..4e96cc37fbedf 100644
@@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)
 		return 0;
 
 	/* CLKOUT passes through CLKIN with divider of 1 */
-	clkout_hw = devm_clk_hw_register_divider(dev, "clkout", __clk_get_name(st->clkin),
-						 CLK_SET_RATE_PARENT, NULL, 0, 1, 0, NULL);
+	clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout",
+						      __clk_get_name(st->clkin),
+						      CLK_SET_RATE_PARENT, 1, 1);
 	if (IS_ERR(clkout_hw))
 		return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to register clkout");
 

base-commit: 6b9f23b5460818aaf199dda90210d5fc08d66c8f

maintainer
#2 lore raw
Quoted 12 lines · On Mon, 31 Aug 2026 00:57:28 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 9 lines · On Wed, 26 Aug 2026 16:31:56 +0800 Linmao Li <[email protected]> wrote:

ade9000_setup_clkout() passes NULL as the register address when registering a divider clock. During clock registration, the common clock framework calls clk_divider_recalc_rate(), which dereferences the address through readl(). As a result, probing an ADE9000 configured as a clock provider with an external input clock crashes.

CLKOUT passes CLKIN through without changing its rate. Register it as a 1:1 fixed-factor clock, which does not require register access.

Quoted 8 lines
Quoted 6 lines

This change does not affect the configuration using the internal clock, for which the driver does not register a clock provider.

Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

Looking for a tag from Antoniu for this one.

Antoniu

Please take a look at this.

Jonathan

Quoted 28 lines
Quoted 26 lines

---
Changes in v2:
- Clarify that the configuration using the internal clock is unaffected.

 drivers/iio/adc/ade9000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +3 -2
index e57e24b6acdf7..4e96cc37fbedf 100644
@@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)
 		return 0;
 
 	/* CLKOUT passes through CLKIN with divider of 1 */
-	clkout_hw = devm_clk_hw_register_divider(dev, "clkout", __clk_get_name(st->clkin),
-						 CLK_SET_RATE_PARENT, NULL, 0, 1, 0, NULL);
+	clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout",
+						      __clk_get_name(st->clkin),
+						      CLK_SET_RATE_PARENT, 1, 1);
 	if (IS_ERR(clkout_hw))
 		return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to register clkout");
 

base-commit: 6b9f23b5460818aaf199dda90210d5fc08d66c8f

maintainer Reviewed-by
#3 lore raw

--
Antoniu Miclăuş

Quoted 30 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Monday, September 21, 2026 6:12 AM
To: Linmao Li <[email protected]>; Miclaus, Antoniu <[email protected]>
Cc: Sa, Nuno <[email protected]>; Hennerich, Michael <[email protected]>; David Lechner <[email protected]>; Andy Shevchenko <[email protected]>; linux <[email protected]>; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] iio: adc: ade9000: fix NULL pointer dereference in clkout registration

Quoted 15 lines · On Mon, 31 Aug 2026 00:57:28 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 12 lines · On Wed, 26 Aug 2026 16:31:56 +0800 Linmao Li <[email protected]> wrote:

ade9000_setup_clkout() passes NULL as the register address when registering a divider clock. During clock registration, the common clock framework calls clk_divider_recalc_rate(), which dereferences the address through readl(). As a result, probing an ADE9000 configured as a clock provider with an external input clock crashes.

CLKOUT passes CLKIN through without changing its rate. Register it as a 1:1 fixed-factor clock, which does not require register access.

This change does not affect the configuration using the internal clock, for which the driver does not register a clock provider.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

Looking for a tag from Antoniu for this one.

Antoniu

Please take a look at this.

Sorry for the late response, thanks for the ping!

Quoted 22 lines

Jonathan

Quoted 5 lines
Quoted 5 lines

---
Changes in v2:
- Clarify that the configuration using the internal clock is unaffected.

Quoted 8 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device

Quoted 8 lines
 drivers/iio/adc/ade9000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +0 -0
index e57e24b6acdf7..4e96cc37fbedf 100644
@@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device

*dev, struct ade9000_state *st)

Quoted 4 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)

Quoted 4 lines
drivers/iio/adc/ade9000.c +0 -1
 		return 0;
 
 	/* CLKOUT passes through CLKIN with divider of 1 */
-	clkout_hw = devm_clk_hw_register_divider(dev, "clkout",

__clk_get_name(st->clkin),

Quoted 6 lines
Quoted 1 line

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device · line 1651

Quoted 1 line
drivers/iio/adc/ade9000.c +0 -1
-						 CLK_SET_RATE_PARENT,

NULL, 0, 1, 0, NULL);

Quoted 3 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)

Quoted 3 lines
drivers/iio/adc/ade9000.c +3 -0
+	clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout",
+						      __clk_get_name(st->clkin),
+						      CLK_SET_RATE_PARENT, 1,

1);

Quoted 8 lines
Quoted 2 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device · line 1654

Quoted 2 lines
drivers/iio/adc/ade9000.c +0 -0
 	if (IS_ERR(clkout_hw))
 		return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to

register clkout");

Quoted 5 lines
Quoted 3 lines

base-commit: 6b9f23b5460818aaf199dda90210d5fc08d66c8f

maintainer Applied
#4 lore raw
Quoted 66 lines · Antoniu

--
Antoniu Miclăuş

Quoted 30 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Monday, September 21, 2026 6:12 AM
To: Linmao Li <[email protected]>; Miclaus, Antoniu <[email protected]>
Cc: Sa, Nuno <[email protected]>; Hennerich, Michael <[email protected]>; David Lechner <[email protected]>; Andy Shevchenko <[email protected]>; linux <[email protected]>; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] iio: adc: ade9000: fix NULL pointer dereference in clkout registration

Quoted 15 lines · On Mon, 31 Aug 2026 00:57:28 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 12 lines · On Wed, 26 Aug 2026 16:31:56 +0800 Linmao Li <[email protected]> wrote:

ade9000_setup_clkout() passes NULL as the register address when registering a divider clock. During clock registration, the common clock framework calls clk_divider_recalc_rate(), which dereferences the address through readl(). As a result, probing an ADE9000 configured as a clock provider with an external input clock crashes.

CLKOUT passes CLKIN through without changing its rate. Register it as a 1:1 fixed-factor clock, which does not require register access.

This change does not affect the configuration using the internal clock, for which the driver does not register a clock provider.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

Looking for a tag from Antoniu for this one.

Antoniu

Please take a look at this.

Sorry for the late response, thanks for the ping!

Quoted 22 lines

Jonathan

Quoted 5 lines
Quoted 5 lines

---
Changes in v2:
- Clarify that the configuration using the internal clock is unaffected.

Quoted 8 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device

Quoted 8 lines
 drivers/iio/adc/ade9000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +0 -0
index e57e24b6acdf7..4e96cc37fbedf 100644
@@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device  

*dev, struct ade9000_state *st)

Quoted 4 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)

Quoted 4 lines
drivers/iio/adc/ade9000.c +0 -1
 		return 0;
 
 	/* CLKOUT passes through CLKIN with divider of 1 */
-	clkout_hw = devm_clk_hw_register_divider(dev, "clkout",  

__clk_get_name(st->clkin),

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device · line 1651

Quoted 1 line
drivers/iio/adc/ade9000.c +0 -1
-						 CLK_SET_RATE_PARENT,  

NULL, 0, 1, 0, NULL);

Quoted 3 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st)

Quoted 3 lines
drivers/iio/adc/ade9000.c +3 -0
+	clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout",
+						      __clk_get_name(st->clkin),
+						      CLK_SET_RATE_PARENT, 1,  

1);

Applied to the fixes-togreg branch of iio.git
Not that will probably not go upstream until the next merge window.

Thanks,

Jonathan

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

drivers/iio/adc/ade9000.c static int ade9000_setup_clkout(struct device · line 1654

Quoted 2 lines
drivers/iio/adc/ade9000.c +0 -0
 	if (IS_ERR(clkout_hw))
 		return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to  

register clkout");

Quoted 5 lines
Quoted 3 lines

base-commit: 6b9f23b5460818aaf199dda90210d5fc08d66c8f