* [PATCH] ASoC: wm8962: potential use of error pointer
@ 2021-12-17 3:13 Jiasheng Jiang
2021-12-17 9:42 ` Cezary Rojewski
2021-12-17 9:46 ` Charles Keepax
0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2021-12-17 3:13 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx,
shengjiu.wang, daniel.baluta
Cc: patches, alsa-devel, linux-kernel, Jiasheng Jiang
The return value of devm_clk_get() needs to be checked.
To avoid use of error pointer in case of the failure of alloc.
Fixes: d74e9e7090ae ("ASoC: wm8962: Add device tree binding")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
sound/soc/codecs/wm8962.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 34080f497584..66693bf17763 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3540,6 +3540,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
}
pdata->mclk = devm_clk_get(&i2c->dev, NULL);
+ if (IS_ERR(pdata->mclk))
+ return -ENOMEM;
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: wm8962: potential use of error pointer
2021-12-17 3:13 [PATCH] ASoC: wm8962: potential use of error pointer Jiasheng Jiang
@ 2021-12-17 9:42 ` Cezary Rojewski
2021-12-17 9:46 ` Charles Keepax
1 sibling, 0 replies; 3+ messages in thread
From: Cezary Rojewski @ 2021-12-17 9:42 UTC (permalink / raw)
To: Jiasheng Jiang, lgirdwood, broonie, perex, tiwai,
kuninori.morimoto.gx, shengjiu.wang, daniel.baluta
Cc: patches, alsa-devel, linux-kernel
On 2021-12-17 4:13 AM, Jiasheng Jiang wrote:
> The return value of devm_clk_get() needs to be checked.
> To avoid use of error pointer in case of the failure of alloc.
>
> Fixes: d74e9e7090ae ("ASoC: wm8962: Add device tree binding")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> sound/soc/codecs/wm8962.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 34080f497584..66693bf17763 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -3540,6 +3540,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
> }
>
> pdata->mclk = devm_clk_get(&i2c->dev, NULL);
> + if (IS_ERR(pdata->mclk))
> + return -ENOMEM;
>
> return 0;
> }
>
Correct me if I'm wrong, but -ENOMEM is not the only error code that
could get returned by clk_get() (which is internally called by
devm_clk_get()). Is there a specific reason for ignoring the return value?
Regards,
Czarek
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: wm8962: potential use of error pointer
2021-12-17 3:13 [PATCH] ASoC: wm8962: potential use of error pointer Jiasheng Jiang
2021-12-17 9:42 ` Cezary Rojewski
@ 2021-12-17 9:46 ` Charles Keepax
1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2021-12-17 9:46 UTC (permalink / raw)
To: Jiasheng Jiang
Cc: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx,
shengjiu.wang, daniel.baluta, patches, alsa-devel, linux-kernel
On Fri, Dec 17, 2021 at 11:13:33AM +0800, Jiasheng Jiang wrote:
> The return value of devm_clk_get() needs to be checked.
> To avoid use of error pointer in case of the failure of alloc.
>
> Fixes: d74e9e7090ae ("ASoC: wm8962: Add device tree binding")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> sound/soc/codecs/wm8962.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 34080f497584..66693bf17763 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -3540,6 +3540,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
> }
>
> pdata->mclk = devm_clk_get(&i2c->dev, NULL);
> + if (IS_ERR(pdata->mclk))
> + return -ENOMEM;
The value was checked later, so the code was mostly fine and what
bugs there were have already been fixed:
044c11401443 ("ASoC: wm8962: Convert to devm_clk_get_optional")
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-17 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 3:13 [PATCH] ASoC: wm8962: potential use of error pointer Jiasheng Jiang
2021-12-17 9:42 ` Cezary Rojewski
2021-12-17 9:46 ` Charles Keepax
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®