linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read
@ 2022-12-29 18:40 Samuel Holland
  2022-12-29 18:40 ` [PATCH 2/2] rtc: sun6i: Drop the unused has_out_clk flag Samuel Holland
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Samuel Holland @ 2022-12-29 18:40 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Chen-Yu Tsai, Jernej Skrabec
  Cc: linux-arm-kernel, linux-rtc, linux-kernel, linux-sunxi,
	Samuel Holland

If there is more than one parent clock in the devicetree, the
driver sets .num_parents to a larger value than the number of array
elements, which causes an out-of-bounds read in the clock framework.

Fix this by coercing the parent count to a Boolean value, like the
driver expects.

Fixes: 3855c2c3e546 ("rtc: sun6i: Expose the 32kHz oscillator")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/rtc/rtc-sun6i.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index ed5516089e9a..a22358a44e32 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -294,7 +294,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 
 	init.parent_names = parents;
 	/* ... number of clock parents will be 1. */
-	init.num_parents = of_clk_get_parent_count(node) + 1;
+	init.num_parents = !!of_clk_get_parent_count(node) + 1;
 	of_property_read_string_index(node, "clock-output-names", 0,
 				      &init.name);
 
-- 
2.37.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-02-12 21:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-29 18:40 [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read Samuel Holland
2022-12-29 18:40 ` [PATCH 2/2] rtc: sun6i: Drop the unused has_out_clk flag Samuel Holland
2023-01-05 17:18   ` Jernej Škrabec
2023-01-05 17:26 ` [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read Jernej Škrabec
2023-01-07 17:15   ` Samuel Holland
2023-01-08 19:39     ` Jernej Škrabec
2023-02-12 21:10       ` Samuel Holland
2023-02-09 22:49 ` Alexandre Belloni
2023-02-12 21:11   ` Samuel Holland

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