2023-11-17 07:49:56

by Alexandra Diupina

[permalink] [raw]
Subject: [PATCH] cpufreq: scmi: process the result of devm_of_clk_add_hw_provider()

devm_of_clk_add_hw_provider() may return an errno, so
add a return value check

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 8410e7f3b31e ("cpufreq: scmi: Fix OPP addition failure with a dummy clock provider")
Signed-off-by: Alexandra Diupina <[email protected]>
---
drivers/cpufreq/scmi-cpufreq.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index c8a7ccc42c16..4037945663bf 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -334,8 +334,13 @@ static int scmi_cpufreq_probe(struct scmi_device *sdev)

#ifdef CONFIG_COMMON_CLK
/* dummy clock provider as needed by OPP if clocks property is used */
- if (of_property_present(dev->of_node, "#clock-cells"))
- devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
+ if (of_property_present(dev->of_node, "#clock-cells")) {
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
+ if (ret) {
+ dev_err(dev, "%s: registering clock provider failed, err: %d\n",
+ __func__, ret);
+ }
+ }
#endif

ret = cpufreq_register_driver(&scmi_cpufreq_driver);
--
2.30.2


2023-11-17 11:14:47

by Alexandra Diupina

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: scmi: process the result of devm_of_clk_add_hw_provider()

I'm sorry, I forgot to add "return ret;" after
calling the dev_err() function. Before I post
the second version of the patch, please let me
know what you think about this fix, keeping in
mind what I wanted to add "return ret;"

17.11.2023 10:49, Alexandra Diupina пишет:
> devm_of_clk_add_hw_provider() may return an errno, so
> add a return value check
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 8410e7f3b31e ("cpufreq: scmi: Fix OPP addition failure with a dummy clock provider")
> Signed-off-by: Alexandra Diupina <[email protected]>
> ---
> drivers/cpufreq/scmi-cpufreq.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
> index c8a7ccc42c16..4037945663bf 100644
> --- a/drivers/cpufreq/scmi-cpufreq.c
> +++ b/drivers/cpufreq/scmi-cpufreq.c
> @@ -334,8 +334,13 @@ static int scmi_cpufreq_probe(struct scmi_device *sdev)
>
> #ifdef CONFIG_COMMON_CLK
> /* dummy clock provider as needed by OPP if clocks property is used */
> - if (of_property_present(dev->of_node, "#clock-cells"))
> - devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
> + if (of_property_present(dev->of_node, "#clock-cells")) {
> + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
> + if (ret) {
> + dev_err(dev, "%s: registering clock provider failed, err: %d\n",
> + __func__, ret);
> + }
> + }
> #endif
>
> ret = cpufreq_register_driver(&scmi_cpufreq_driver);


Regards,

Alexandra Diupina

2023-11-18 07:01:20

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: scmi: process the result of devm_of_clk_add_hw_provider()

Le 17/11/2023 à 12:14, Александра Дюпина a écrit :
> I'm sorry, I forgot to add "return ret;" after
> calling the dev_err() function. Before I post
> the second version of the patch, please let me
> know what you think about this fix, keeping in
> mind what I wanted to add "return ret;"

This is a probe function.
So, maybe using dev_err_probe() would be slightly nicer?

If yes, the dev_err() that is already there could be updated as well in
an other patch.

CJ

>
> 17.11.2023 10:49, Alexandra Diupina пишет:
>> devm_of_clk_add_hw_provider() may return an errno, so
>> add a return value check
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Fixes: 8410e7f3b31e ("cpufreq: scmi: Fix OPP addition failure with a
>> dummy clock provider")
>> Signed-off-by: Alexandra Diupina <[email protected]>
>> ---
>>   drivers/cpufreq/scmi-cpufreq.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/scmi-cpufreq.c
>> b/drivers/cpufreq/scmi-cpufreq.c
>> index c8a7ccc42c16..4037945663bf 100644
>> --- a/drivers/cpufreq/scmi-cpufreq.c
>> +++ b/drivers/cpufreq/scmi-cpufreq.c
>> @@ -334,8 +334,13 @@ static int scmi_cpufreq_probe(struct scmi_device
>> *sdev)
>>   #ifdef CONFIG_COMMON_CLK
>>       /* dummy clock provider as needed by OPP if clocks property is
>> used */
>> -    if (of_property_present(dev->of_node, "#clock-cells"))
>> -        devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
>> +    if (of_property_present(dev->of_node, "#clock-cells")) {
>> +        ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
>> NULL);
>> +        if (ret) {
>> +            dev_err(dev, "%s: registering clock provider failed, err:
>> %d\n",
>> +                __func__, ret);
>> +        }
>> +    }
>>   #endif
>>       ret = cpufreq_register_driver(&scmi_cpufreq_driver);
>
>
> Regards,
>
> Alexandra Diupina
>

2023-12-05 15:13:32

by Alexandra Diupina

[permalink] [raw]
Subject: [PATCH v2] cpufreq: scmi: process the result of devm_of_clk_add_hw_provider()

devm_of_clk_add_hw_provider() may return an errno, so
add a return value check

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 8410e7f3b31e ("cpufreq: scmi: Fix OPP addition failure with a dummy clock provider")
Signed-off-by: Alexandra Diupina <[email protected]>
---
v2: replace dev_err() with dev_err_probe() as
Christophe JAILLET <[email protected]> suggested
drivers/cpufreq/scmi-cpufreq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index c8a7ccc42c16..4ee23f4ebf4a 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -334,8 +334,11 @@ static int scmi_cpufreq_probe(struct scmi_device *sdev)

#ifdef CONFIG_COMMON_CLK
/* dummy clock provider as needed by OPP if clocks property is used */
- if (of_property_present(dev->of_node, "#clock-cells"))
- devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
+ if (of_property_present(dev->of_node, "#clock-cells")) {
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
+ if (ret)
+ return dev_err_probe(dev, ret, "%s: registering clock provider failed\n", __func__);
+ }
#endif

ret = cpufreq_register_driver(&scmi_cpufreq_driver);
--
2.30.2

2023-12-06 06:11:29

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH v2] cpufreq: scmi: process the result of devm_of_clk_add_hw_provider()

On 05-12-23, 18:12, Alexandra Diupina wrote:
> devm_of_clk_add_hw_provider() may return an errno, so
> add a return value check
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 8410e7f3b31e ("cpufreq: scmi: Fix OPP addition failure with a dummy clock provider")
> Signed-off-by: Alexandra Diupina <[email protected]>
> ---
> v2: replace dev_err() with dev_err_probe() as
> Christophe JAILLET <[email protected]> suggested
> drivers/cpufreq/scmi-cpufreq.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
> index c8a7ccc42c16..4ee23f4ebf4a 100644
> --- a/drivers/cpufreq/scmi-cpufreq.c
> +++ b/drivers/cpufreq/scmi-cpufreq.c
> @@ -334,8 +334,11 @@ static int scmi_cpufreq_probe(struct scmi_device *sdev)
>
> #ifdef CONFIG_COMMON_CLK
> /* dummy clock provider as needed by OPP if clocks property is used */
> - if (of_property_present(dev->of_node, "#clock-cells"))
> - devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
> + if (of_property_present(dev->of_node, "#clock-cells")) {
> + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, NULL);
> + if (ret)
> + return dev_err_probe(dev, ret, "%s: registering clock provider failed\n", __func__);
> + }
> #endif
>
> ret = cpufreq_register_driver(&scmi_cpufreq_driver);

Applied. Thanks.

--
viresh