ASoC trivial fixes
Subsystems (4)
cover ASoC trivial fixes
Hi,
this is a series of fixes for the bugs I pointed yesterday. Since no fix action was seen yet, I quickly put band-aid over them.
thanks,
Takashi
PATCH 1/4 ASoC: mc13783: Fix of_node_put() call with uninitialized object
The commit [a28d167fbbef: ASoC: mc13783: Add missing of_node_put]
fixed the leak of OF node, but it calls of_node_put() unconditionally
at error path where the passed pointer might be uninitialized. It was
caught by a compiler warning:
sound/soc/codecs/mc13783.c:787:13: warning: 'np' may be used uninitialized in this function [-Wuninitialized]
This patch adds the NULL initialization properly for fixing this.
--- sound/soc/codecs/mc13783.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/mc13783.c +1 -1
@@ -749,7 +749,7 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) {struct mc13783_priv *priv;struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data; -struct device_node *np; +struct device_node *np =NULL ;int ret; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );
Signature · 1 line
2.1.2
Mark Brown
maintainerRe: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
sound/soc/codecs/mc13783.c static int __init mc13783_codec_probe(struct platform_device *pdev) · line 752
Quoted 2 lines · Takashi Iwai
sound/soc/codecs/mc13783.c +1
-1-struct device_node *np; +struct device_node *np =NULL ;
No, unconditional initialisations like this are worse than the problem they're trying to fix.
Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
At Tue, 7 Oct 2014 18:09:38 +0100,
Quoted 8 lines · Mark Brown
sound/soc/codecs/mc13783.c static int __init mc13783_codec_probe(struct platform_device *pdev) · line 752
Quoted 2 lines · Takashi Iwai
sound/soc/codecs/mc13783.c +1
-1-struct device_node *np; +struct device_node *np =NULL ;No, unconditional initialisations like this are worse than the problem they're trying to fix.
Which problem they're trying to fix...?
Initializing with NULL for the of_node_put() at error path is a standard idiom. An alternative fix would be to add "if (!pdata)" before of_node_put(np). But this isn't really intuitive, either (and even more error-prone, IMO).
Takashi
Mark Brown
maintainerRe: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Mark Brown
sound/soc/codecs/mc13783.c static int __init mc13783_codec_probe(struct platform_device *pdev) · line 752
Quoted 2 lines · Takashi Iwai
sound/soc/codecs/mc13783.c +1
-1-struct device_node *np; +struct device_node *np =NULL ;No, unconditional initialisations like this are worse than the problem they're trying to fix.
Which problem they're trying to fix...?
Shutting up warnings - because they just brute forcing they mean that if there's anything else we've missed the compiler won't be able to tell us about it.
Quoted 4 lines
Initializing with NULL for the
of_node_put()at error path is a standard idiom. An alternative fix would be to add "if (!pdata)" beforeof_node_put(np). But this isn't really intuitive, either (and even more error-prone, IMO).
Well, in this case I'd just move the of_node_put() into the existing check for pdata since we don't ever reference np outside of that anyway.
Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
At Tue, 7 Oct 2014 18:23:37 +0100,
Quoted 18 lines · Mark Brown
Quoted 11 lines · Takashi Iwai
Quoted 7 lines · Mark Brown
sound/soc/codecs/mc13783.c static int __init mc13783_codec_probe(struct platform_device *pdev) · line 752
Quoted 2 lines · Takashi Iwai
sound/soc/codecs/mc13783.c +1
-1-struct device_node *np; +struct device_node *np =NULL ;No, unconditional initialisations like this are worse than the problem they're trying to fix.
Which problem they're trying to fix...?
Shutting up warnings - because they just brute forcing they mean that if there's anything else we've missed the compiler won't be able to tell us about it.
Quoted 7 lines
Quoted 4 lines
Initializing with NULL for the
of_node_put()at error path is a standard idiom. An alternative fix would be to add "if (!pdata)" beforeof_node_put(np). But this isn't really intuitive, either (and even more error-prone, IMO).Well, in this case I'd just move the
of_node_put()into the existing check for pdata since we don't ever reference np outside of that anyway.
Yeah, that's an option, too, but it'd make the code less readable. So I chose the straightforward way.
Takashi
Mark Brown
maintainerRe: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
Quoted 7 lines · Takashi Iwai
Quoted 2 lines · Mark Brown
Well, in this case I'd just move the
of_node_put()into the existing check for pdata since we don't ever reference np outside of that anyway.Yeah, that's an option, too, but it'd make the code less readable. So I chose the straightforward way.
I don't actually see it as a readability concern - to me having the get and release close to each other and especially having them at the same level of indentation helps.
Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
At Tue, 7 Oct 2014 19:04:34 +0100,
Quoted 7 lines · Mark Brown
Quoted 4 lines · Takashi Iwai
Quoted 2 lines · Mark Brown
Well, in this case I'd just move the
of_node_put()into the existing check for pdata since we don't ever reference np outside of that anyway.
Quoted 6 lines
Quoted 2 lines
Yeah, that's an option, too, but it'd make the code less readable. So I chose the straightforward way.
I don't actually see it as a readability concern - to me having the get and release close to each other and especially having them at the same level of indentation helps.
I do understand the merit, but it looks uglier to my taste. The success path goes again with if (ret). (Or we'd need two goto's or deeper if-else blocks.)
Takashi
sound/soc/codecs/mc13783.c +6 -3
@@ -749,7 +749,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) {struct mc13783_priv *priv;struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data; -struct device_node *np;int ret; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );
@@ -760,6 +759,8 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) priv->adc_ssi_port = pdata->adc_ssi_port; priv->dac_ssi_port = pdata->dac_ssi_port; }else { +struct device_node *np; + np =of_get_child_by_name (pdev->dev.parent->of_node,"codec" );if (!np)return -ENOSYS ;
@@ -771,6 +772,10 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) ret =of_property_read_u32 (np,"dac-port" , &priv->dac_ssi_port);if (ret) goto out; + out: +of_node_put (np); +if (ret) +return ret; }dev_set_drvdata (&pdev->dev, priv);
@@ -783,8 +788,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) ret =snd_soc_register_codec (&pdev->dev, &soc_codec_dev_mc13783, mc13783_dai_async,ARRAY_SIZE (mc13783_dai_async)); -out: -of_node_put (np);return ret; }
Mark Brown
maintainerRe: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
Quoted 9 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
I don't actually see it as a readability concern - to me having the get and release close to each other and especially having them at the same level of indentation helps.
I do understand the merit, but it looks uglier to my taste. The success path goes again with if (ret). (Or we'd need two goto's or deeper if-else blocks.)
That looks ugly, yes - I'd be doing a check for ret before the second property call or something. Or just put the pdata check in the existing error path.
Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
At Tue, 7 Oct 2014 19:54:43 +0100,
Quoted 8 lines · Mark Brown
Quoted 5 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
I don't actually see it as a readability concern - to me having the get and release close to each other and especially having them at the same level of indentation helps.
Quoted 7 lines
Quoted 3 lines
I do understand the merit, but it looks uglier to my taste. The success path goes again with if (ret). (Or we'd need two goto's or deeper if-else blocks.)
That looks ugly, yes - I'd be doing a check for ret before the second property call or something. Or just put the pdata check in the existing error path.
Well, I don't mind much how it'll be fixed, so I rather toss this fix to you. Feel free to cook :)
Takashi
Mark Brown
maintainerRe: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
That looks ugly, yes - I'd be doing a check for ret before the second property call or something. Or just put the pdata check in the existing error path.
Well, I don't mind much how it'll be fixed, so I rather toss this fix to you. Feel free to cook :)
Well, I can't even see the warning so as far as I can tell it's all fixed!
Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object
At Wed, 8 Oct 2014 00:01:50 +0100,
Quoted 8 lines · Mark Brown
Quoted 5 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
That looks ugly, yes - I'd be doing a check for ret before the second property call or something. Or just put the pdata check in the existing error path.
Quoted 5 lines
Quoted 2 lines
Well, I don't mind much how it'll be fixed, so I rather toss this fix to you. Feel free to cook :)
Well, I can't even see the warning so as far as I can tell it's all fixed!
Oh, rather trust your eyes, the fault is there obviously. It's a real bug that can be easily triggered, not in an exceptional error path.
BTW, putting pdata check in the exit path is more error-prone, as already mentioned. If anyone puts a new code with "goto out" before assignment of np, it hits again. So, a NULL initialization would be safer in the end.
Takashi
PATCH 2/4 ASoC: eukrea-tlv320: Fix of_node_put() call with uninitialized object
In reply to Takashi IwaiThe of_node_put() call in eukrea_tlv320_probe() may take an
uninitialized pointer, as compiler spotted out:
sound/soc/codecs/mc13783.c:787:13: warning: 'np' may be used uninitialized in this function [-Wuninitialized]
This patch adds the proper NULL initialization as a fix.
--- sound/soc/fsl/eukrea-tlv320.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/eukrea-tlv320.c +1 -1
@@ -105,7 +105,7 @@ static int eukrea_tlv320_probe(struct platform_device *pdev)int ret;int int_port =0 , ext_port;struct device_node *np = pdev->dev.of_node; -struct device_node *ssi_np, *codec_np; +struct device_node *ssi_np =NULL , *codec_np; eukrea_tlv320.dev = &pdev->dev;if (np) {
Signature · 1 line
2.1.2
Mark Brown
maintainerRe: [PATCH 2/4] ASoC: eukrea-tlv320: Fix of_node_put() call with uninitialized object
sound/soc/fsl/eukrea-tlv320.c static int eukrea_tlv320_probe(struct platform_device *pdev) · line 108
Quoted 2 lines · Takashi Iwai
sound/soc/fsl/eukrea-tlv320.c +1
-1-struct device_node *ssi_np, *codec_np; +struct device_node *ssi_np =NULL , *codec_np;
As well as the NULL thing mixing initialized and unintialized things in one declaration is something that's normally avoided.
Re: [PATCH 2/4] ASoC: eukrea-tlv320: Fix of_node_put() call with uninitialized object
At Tue, 7 Oct 2014 18:18:00 +0100,
Quoted 8 lines · Mark Brown
sound/soc/fsl/eukrea-tlv320.c static int eukrea_tlv320_probe(struct platform_device *pdev) · line 108
Quoted 2 lines · Takashi Iwai
sound/soc/fsl/eukrea-tlv320.c +1
-1-struct device_node *ssi_np, *codec_np; +struct device_node *ssi_np =NULL , *codec_np;As well as the NULL thing mixing initialized and unintialized things in one declaration is something that's normally avoided.
I thought of that, too. For simplicity, we can do NULL initializations for both, of course, if you prefer.
Takashi
PATCH v2 2/4 ASoC: eukrea-tlv320: Fix of_node_put() call with uninitialized object
The of_node_put() call in eukrea_tlv320_probe() may take an
uninitialized pointer, as compiler spotted out:
sound/soc/fsl/eukrea-tlv320.c:221:14: warning: 'ssi_np' may be used uninitialized in this function [-Wuninitialized]
This patch adds the proper NULL initializations as a fix. (codec_np is also NULL initialized just for consistency.)
--- sound/soc/fsl/eukrea-tlv320.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/eukrea-tlv320.c +1 -1
@@ -105,7 +105,7 @@ static int eukrea_tlv320_probe(struct platform_device *pdev)int ret;int int_port =0 , ext_port;struct device_node *np = pdev->dev.of_node; -struct device_node *ssi_np, *codec_np; +struct device_node *ssi_np =NULL , *codec_np =NULL ; eukrea_tlv320.dev = &pdev->dev;if (np) {
Signature · 1 line
2.1.2
Re: [PATCH v2 2/4] ASoC: eukrea-tlv320: Fix of_node_put() call with uninitialized object
Quoted 3 lines · Takashi Iwai
The
of_node_put()call ineukrea_tlv320_probe()may take an
uninitialized pointer, as compiler spotted out:
sound/soc/fsl/eukrea-tlv320.c:221:14: warning: 'ssi_np' may be used uninitialized in this function [-Wuninitialized]
Applied, but please don't send new patches in the middle of e-mail threads - it can get really confusing trying to work out what the current version of the series looks like.
PATCH 3/4 ASoC: imx-es8328: Fix of_node_put() call with uninitialized object
In reply to Takashi IwaiThe of_node_put() calls in imx_es8328_probe() may take uninitialized pointers when reached though the early error path. This patch adds the proper NULL initialization for fixing these.
--- sound/soc/fsl/imx-es8328.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/imx-es8328.c +1 -1
@@ -78,7 +78,7 @@ static const struct snd_soc_dapm_widget imx_es8328_dapm_widgets[] = {static int imx_es8328_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct device_node *ssi_np, *codec_np; +struct device_node *ssi_np =NULL , *codec_np =NULL ;struct platform_device *ssi_pdev;struct imx_es8328_data *data;u32 int_port, ext_port;
Signature · 1 line
2.1.2
Re: [PATCH 3/4] ASoC: imx-es8328: Fix of_node_put() call with uninitialized object
Quoted 3 lines · Takashi Iwai
The
of_node_put()calls inimx_es8328_probe()may take uninitialized pointers when reached though the early error path. This patch adds the proper NULL initialization for fixing these.
Applied, thanks.
PATCH 4/4 ASoC: imx-es8328: Fix missing return code in imx_es8328_probe()
In reply to Takashi IwaiAn error code was forgotten to be passed in the error path of imx_es8328_probe().
--- sound/soc/fsl/imx-es8328.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/fsl/imx-es8328.c +1 -0
@@ -104,6 +104,7 @@ static int imx_es8328_probe(struct platform_device *pdev)if (ext_port >MUX_PORT_MAX || ext_port ==0 ) {dev_err (dev,"mux-ext-port: hardware only has %d mux ports\n" ,MUX_PORT_MAX ); + ret = -EINVAL ; goto fail; }
Signature · 1 line
2.1.2
Re: [PATCH 4/4] ASoC: imx-es8328: Fix missing return code in imx_es8328_probe()
Quoted 2 lines · Takashi Iwai
An error code was forgotten to be passed in the error path of
imx_es8328_probe().
Applied, thanks.
Mark Brown
maintainerQuoted 2 lines · Takashi Iwai
this is a series of fixes for the bugs I pointed yesterday. Since no fix action was seen yet, I quickly put band-aid over them.
So, I now checked who you'd Cced - you didn't CC the Freescale guys so I'm not surprised you got no reply...
At Tue, 7 Oct 2014 18:11:34 +0100,
Quoted 8 lines · Mark Brown
Quoted 2 lines · Takashi Iwai
this is a series of fixes for the bugs I pointed yesterday. Since no fix action was seen yet, I quickly put band-aid over them.
So, I now checked who you'd Cced - you didn't CC the Freescale guys so I'm not surprised you got no reply...
Ah, right, I missed them for these parts.
Takashi