* [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure
@ 2026-06-29 16:21 Vladimir Zapolskiy
2026-06-30 8:50 ` Konrad Dybcio
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Zapolskiy @ 2026-06-29 16:21 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Michael Turquette, Stephen Boyd, Brian Masney, linux-arm-msm,
linux-clk
If a dynamic memory allocation fails, the returned error code in clock
controller driver probe functions on a few legacy platforms should be
set to -ENOMEM instead of -EINVAL.
Fixes: ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")
Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
---
drivers/clk/qcom/common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index eec369d2173b..0e8f380873af 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -169,7 +169,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
if (!node) {
fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
if (!fixed)
- return -EINVAL;
+ return -ENOMEM;
fixed->fixed_rate = rate;
fixed->hw.init = &init_data;
@@ -186,7 +186,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
if (add_factor) {
factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL);
if (!factor)
- return -EINVAL;
+ return -ENOMEM;
factor->mult = factor->div = 1;
factor->hw.init = &init_data;
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure
2026-06-29 16:21 [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure Vladimir Zapolskiy
@ 2026-06-30 8:50 ` Konrad Dybcio
2026-07-01 10:01 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Konrad Dybcio @ 2026-06-30 8:50 UTC (permalink / raw)
To: Vladimir Zapolskiy, Bjorn Andersson, Dan Carpenter
Cc: Michael Turquette, Stephen Boyd, Brian Masney, linux-arm-msm,
linux-clk
On 6/29/26 6:21 PM, Vladimir Zapolskiy wrote:
> If a dynamic memory allocation fails, the returned error code in clock
> controller driver probe functions on a few legacy platforms should be
> set to -ENOMEM instead of -EINVAL.
>
> Fixes: ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")
> Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
> ---
Hm, I'dve assumed that static checkers would be able to find this pattern
+Dan do you still work on smatch nowadays? It doesn't seem to
catch this one, but I think it'd be valuable to look for this pattern
- AFAICS it only flags returning -1 instead of -ENOMEM but I can't
seem to trigger it with a manual edit to this file and the following
args:
-p=kernel --pedantic --two-passes --assume-loops
For the patch
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
> drivers/clk/qcom/common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
> index eec369d2173b..0e8f380873af 100644
> --- a/drivers/clk/qcom/common.c
> +++ b/drivers/clk/qcom/common.c
> @@ -169,7 +169,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
> if (!node) {
> fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
> if (!fixed)
> - return -EINVAL;
> + return -ENOMEM;
>
> fixed->fixed_rate = rate;
> fixed->hw.init = &init_data;
> @@ -186,7 +186,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
> if (add_factor) {
> factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL);
> if (!factor)
> - return -EINVAL;
> + return -ENOMEM;
>
> factor->mult = factor->div = 1;
> factor->hw.init = &init_data;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure
2026-06-30 8:50 ` Konrad Dybcio
@ 2026-07-01 10:01 ` Dan Carpenter
2026-07-01 10:37 ` Konrad Dybcio
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2026-07-01 10:01 UTC (permalink / raw)
To: Konrad Dybcio
Cc: Vladimir Zapolskiy, Bjorn Andersson, Michael Turquette,
Stephen Boyd, Brian Masney, linux-arm-msm, linux-clk
On Tue, Jun 30, 2026 at 10:50:13AM +0200, Konrad Dybcio wrote:
> On 6/29/26 6:21 PM, Vladimir Zapolskiy wrote:
> > If a dynamic memory allocation fails, the returned error code in clock
> > controller driver probe functions on a few legacy platforms should be
> > set to -ENOMEM instead of -EINVAL.
> >
> > Fixes: ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")
> > Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
> > ---
>
> Hm, I'dve assumed that static checkers would be able to find this pattern
>
> +Dan do you still work on smatch nowadays? It doesn't seem to
> catch this one, but I think it'd be valuable to look for this pattern
> - AFAICS it only flags returning -1 instead of -ENOMEM but I can't
> seem to trigger it with a manual edit to this file and the following
> args:
>
> -p=kernel --pedantic --two-passes --assume-loops
>
>
> For the patch
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
I'm re-working a bunch of Smatch internals right now. I've
fixed the -1 vs -ENOMEM warning, but it's affected by the re-work
so it's going to be a while before it hits mainline.
I can create a warning for returning -EINVAL or other error
codes instead of -ENOMEM.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure
2026-07-01 10:01 ` Dan Carpenter
@ 2026-07-01 10:37 ` Konrad Dybcio
0 siblings, 0 replies; 4+ messages in thread
From: Konrad Dybcio @ 2026-07-01 10:37 UTC (permalink / raw)
To: Dan Carpenter
Cc: Vladimir Zapolskiy, Bjorn Andersson, Michael Turquette,
Stephen Boyd, Brian Masney, linux-arm-msm, linux-clk
On 7/1/26 12:01 PM, Dan Carpenter wrote:
> On Tue, Jun 30, 2026 at 10:50:13AM +0200, Konrad Dybcio wrote:
>> On 6/29/26 6:21 PM, Vladimir Zapolskiy wrote:
>>> If a dynamic memory allocation fails, the returned error code in clock
>>> controller driver probe functions on a few legacy platforms should be
>>> set to -ENOMEM instead of -EINVAL.
>>>
>>> Fixes: ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")
>>> Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
>>> ---
>>
>> Hm, I'dve assumed that static checkers would be able to find this pattern
>>
>> +Dan do you still work on smatch nowadays? It doesn't seem to
>> catch this one, but I think it'd be valuable to look for this pattern
>> - AFAICS it only flags returning -1 instead of -ENOMEM but I can't
>> seem to trigger it with a manual edit to this file and the following
>> args:
>>
>> -p=kernel --pedantic --two-passes --assume-loops
>>
>>
>> For the patch
>>
>> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> I'm re-working a bunch of Smatch internals right now. I've
> fixed the -1 vs -ENOMEM warning, but it's affected by the re-work
> so it's going to be a while before it hits mainline.
>
> I can create a warning for returning -EINVAL or other error
> codes instead of -ENOMEM.
Amazing, thank you!
Konrad
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-01 10:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 16:21 [PATCH] clk: qcom: Return expected ENOMEM error on dynamic allocation failure Vladimir Zapolskiy
2026-06-30 8:50 ` Konrad Dybcio
2026-07-01 10:01 ` Dan Carpenter
2026-07-01 10:37 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox