clk: Make clk_bulk_get_all() return a valid "id"
Subsystems (2)
PATCH 1/1 clk: Make clk_bulk_get_all() return a valid "id"
The adreno driver expects the "id" field of the returned clk_bulk_data to be filled in with strings from the clock-names property.
But due to the use of kmalloc_array() in of_clk_bulk_get_all() it receives a list of bogus pointers instead.
Zero-initialize the "id" field and attempt to populate with strings from the clock-names property to resolve both these issues.
--- drivers/clk/clk-bulk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/clk-bulk.c +4 -1
@@ -18,10 +18,13 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,int ret;int i; -for (i =0 ; i < num_clks; i++) +for (i =0 ; i < num_clks; i++) { + clks[i].id =NULL ; clks[i].clk =NULL ; + }for (i =0 ; i < num_clks; i++) { +of_property_read_string_index (np,"clock-names" , i, &clks[i].id); clks[i].clk =of_clk_get (np, i);if (IS_ERR (clks[i].clk)) { ret =PTR_ERR (clks[i].clk);
Signature · 1 line
2.18.0
Quoted 8 lines · Bjorn Andersson
The adreno driver expects the "id" field of the returned
clk_bulk_datato be filled in with strings from the clock-names property.But due to the use of
kmalloc_array()inof_clk_bulk_get_all()it receives a list of bogus pointers instead.Zero-initialize the "id" field and attempt to populate with strings from the clock-names property to resolve both these issues.
This looks great to me. Thanks for fixing that so quickly.
Quoted 31 lines
Fixes 616e45df7c4a ("clk: add new APIs to operate on all available clocks")Fixes 8e3e791d20d2 ("drm/msm: Use generic bulk clock function")Cc Dong Aisheng <[email protected]>Cc Jordan Crouse <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>--- drivers/clk/clk-bulk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/clk/clk-bulk.c +4
-1@@ -18,10 +18,13 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,int ret;int i; -for (i =0 ; i < num_clks; i++) +for (i =0 ; i < num_clks; i++) { + clks[i].id =NULL ; clks[i].clk =NULL ; + }for (i =0 ; i < num_clks; i++) { +of_property_read_string_index (np,"clock-names" , i, &clks[i].id); clks[i].clk =of_clk_get (np, i);if (IS_ERR (clks[i].clk)) { ret =PTR_ERR (clks[i].clk);Signature · 1 line
2.18.0
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoting Bjorn Andersson (2019-09-12 19:40:29)
Quoted 9 lines
The adreno driver expects the "id" field of the returned
clk_bulk_datato be filled in with strings from the clock-names property.But due to the use of
kmalloc_array()inof_clk_bulk_get_all()it receives a list of bogus pointers instead.Zero-initialize the "id" field and attempt to populate with strings from the clock-names property to resolve both these issues.
Quoted 6 lines
Fixes 616e45df7c4a ("clk: add new APIs to operate on all available clocks")Fixes 8e3e791d20d2 ("drm/msm: Use generic bulk clock function")Cc Dong Aisheng <[email protected]>Cc Jordan Crouse <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>---
Applied to clk-next
And now I see that this whole thing needs to be inlined to the one call site and should use the struct device instead of calling of_clk_get()... I'll have to fix it later.
Quoted 10 lines · Stephen Boyd
Quoting Bjorn Andersson (2019-09-12 19:40:29)
Quoted 9 lines
The adreno driver expects the "id" field of the returned
clk_bulk_datato be filled in with strings from the clock-names property.But due to the use of
kmalloc_array()inof_clk_bulk_get_all()it receives a list of bogus pointers instead.Zero-initialize the "id" field and attempt to populate with strings from the clock-names property to resolve both these issues.
Quoted 9 lines
Quoted 6 lines
Fixes 616e45df7c4a ("clk: add new APIs to operate on all available clocks")Fixes 8e3e791d20d2 ("drm/msm: Use generic bulk clock function")Cc Dong Aisheng <[email protected]>Cc Jordan Crouse <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>---
Applied to clk-next
Thanks
Quoted 4 lines
And now I see that this whole thing needs to be inlined to the one call site and should use the struct device instead of calling
of_clk_get()... I'll have to fix it later.
I concluded the same, sorry for not mentioning it.
Regards,
Bjorn