Skip to content

Commit 2079d02

Browse files
mripardbebarino
authored andcommitted
clk: Initialize the clk_rate_request even if clk_core is NULL
Since commit c35e84b ("clk: Introduce clk_hw_init_rate_request()"), users that used to initialize their clk_rate_request by initializing their local structure now rely on clk_hw_init_rate_request(). This function is backed by clk_core_init_rate_req(), which will skip the initialization if either the pointer to struct clk_core or to struct clk_rate_request are NULL. However, the core->parent pointer might be NULL because the clock is orphan, and we will thus end up with our local struct clk_rate_request left untouched. And since clk_hw_init_rate_request() doesn't return an error, we will then call a determine_rate variant with that unitialized structure. In order to avoid this, let's clear our clk_rate_request if the pointer to it is valid but the pointer to struct clk_core isn't. Fixes: c35e84b ("clk: Introduce clk_hw_init_rate_request()") Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 08a3290 commit 2079d02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/clk/clk.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,14 @@ static void clk_core_init_rate_req(struct clk_core * const core,
14591459
{
14601460
struct clk_core *parent;
14611461

1462-
if (!core || WARN_ON(!req))
1462+
if (WARN_ON(!req))
14631463
return;
14641464

14651465
memset(req, 0, sizeof(*req));
14661466

1467+
if (!core)
1468+
return;
1469+
14671470
req->rate = rate;
14681471
clk_core_get_boundaries(core, &req->min_rate, &req->max_rate);
14691472

0 commit comments

Comments
 (0)