Skip to content

Commit 0296c90

Browse files
DC-fgervaisgregkh
authored andcommitted
rtc: pcf85063: fallback to parent of_node
commit 0353160 upstream. The rtc device node is always NULL. Since v5.12-rc1-dontuse/3c9ea42802a1fbf7ef29660ff8c6e526c58114f6 this will lead to a NULL pointer dereference. To fix this use the parent node which is the i2c client node as set by devm_rtc_allocate_device(). Using the i2c client node seems to be what other similar drivers do e.g. rtc-pcf8563.c. Signed-off-by: Francois Gervais <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7b994b0 commit 0296c90

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/rtc/rtc-pcf85063.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static struct clk *pcf85063_clkout_register_clk(struct pcf85063 *pcf85063)
486486
{
487487
struct clk *clk;
488488
struct clk_init_data init;
489+
struct device_node *node = pcf85063->rtc->dev.parent->of_node;
489490

490491
init.name = "pcf85063-clkout";
491492
init.ops = &pcf85063_clkout_ops;
@@ -495,15 +496,13 @@ static struct clk *pcf85063_clkout_register_clk(struct pcf85063 *pcf85063)
495496
pcf85063->clkout_hw.init = &init;
496497

497498
/* optional override of the clockname */
498-
of_property_read_string(pcf85063->rtc->dev.of_node,
499-
"clock-output-names", &init.name);
499+
of_property_read_string(node, "clock-output-names", &init.name);
500500

501501
/* register the clock */
502502
clk = devm_clk_register(&pcf85063->rtc->dev, &pcf85063->clkout_hw);
503503

504504
if (!IS_ERR(clk))
505-
of_clk_add_provider(pcf85063->rtc->dev.of_node,
506-
of_clk_src_simple_get, clk);
505+
of_clk_add_provider(node, of_clk_src_simple_get, clk);
507506

508507
return clk;
509508
}

0 commit comments

Comments
 (0)