clk: qcom: Return expected ENOMEM error on dynamic allocation failure
Subsystems (3)
PATCH 1/1 clk: qcom: Return expected ENOMEM error on dynamic allocation failure
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.
--- drivers/clk/qcom/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/common.c +2 -2
@@ -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;
Signature · 1 line
2.51.0
Quoted 7 lines · Vladimir Zapolskiy
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
-ENOMEMinstead of-EINVAL.Fixes ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")Signed-off-by Vladimir Zapolskiy <[email protected]>---
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
Konrad
Quoted 25 lines
drivers/clk/qcom/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clk/qcom/common.c +2
-2@@ -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;
Quoted 17 lines · Konrad Dybcio
Quoted 7 lines · Vladimir Zapolskiy
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
-ENOMEMinstead of-EINVAL.Fixes ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")Signed-off-by Vladimir Zapolskiy <[email protected]>---
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-ENOMEMbut I can't seem to trigger it with a manual edit to this file and the following args:
Quoted 6 lines
-p=kernel --pedantic --two-passes --assume-loops
For the patch
Reviewed-by Konrad Dybcio <[email protected]>
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
Quoted 23 lines · Dan Carpenter
Quoted 22 lines · Konrad Dybcio
Quoted 7 lines · Vladimir Zapolskiy
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
-ENOMEMinstead of-EINVAL.Fixes ee15faffef11 ("clk: qcom: common: Add API to register board clocks backwards compatibly")Signed-off-by Vladimir Zapolskiy <[email protected]>---
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-ENOMEMbut 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
Quoted 8 lines
Quoted 1 line
Reviewed-by Konrad Dybcio <[email protected]>I'm re-working a bunch of Smatch internals right now. I've fixed the -1 vs
-ENOMEMwarning, 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
-EINVALor other error codes instead of-ENOMEM.
Amazing, thank you!
Konrad
Quoted 5 lines · Vladimir Zapolskiy
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
-ENOMEMinstead of-EINVAL.
Applied, thanks!
[1/1] clk: qcom: Return expected ENOMEM error on dynamic allocation failure
commit: 22d9257f08913b6eec3e8ece4d13d9c41f14428b
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>