ASoC: soc-pcm: Fix uninitialised return value in variable ret
Subsystems (3)
PATCH 1/1 ASoC: soc-pcm: Fix uninitialised return value in variable ret
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the caller does not report the error "ASoC: failed to shutdown some BEs" and because this failure path has already reported the reason for the early return.
Addresses-Coverity: ("Uninitialized scalar variable")
--- sound/soc/soc-pcm.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/soc-pcm.c +1 -0
@@ -2443,6 +2443,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE) {dev_err (fe->dev,"ASoC: FE %s is not ready %d\n" , fe->dai_link->name, fe->dpcm[stream].state); + ret =0 ; goto disconnect; }
Signature · 1 line
2.29.2
Agree, thanks.
Quoted 30 lines
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the caller does not report the error "ASoC: failed to shutdown some BEs" and because this failure path has already reported the reason for the early return.
Addresses-Coverity: ("Uninitialized scalar variable")
Fixes 2c1382840c19 ("ASoC: soc-pcm: disconnect BEs if the FE is not ready")Signed-off-by Colin Ian King <[email protected]>---
sound/soc/soc-pcm.c| 1 +1 file changed, 1 insertion(+)sound/soc/soc-pcm.c +1
-0@@ -2443,6 +2443,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) {dev_err (fe->dev,"ASoC: FE %s is not ready %d\n" , fe->dai_link->name, fe->dpcm[stream].state); + ret =0 ; goto disconnect; }Signature · 1 line
2.29.2
Mark Brown
maintainerQuoted 5 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the
This doesn't apply against current code, please check and resend.
Quoted 9 lines · Mark Brown
Quoted 5 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the
This doesn't apply against current code, please check and resend.
Just to double-check, which tree should I be working against?
Colin
Mark Brown
maintainerQuoted 5 lines · Colin Ian King
Quoted 1 line · Mark Brown
This doesn't apply against current code, please check and resend.
Just to double-check, which tree should I be working against?
The ASoC tree.
Quoted 9 lines · Mark Brown
Quoted 5 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the
This doesn't apply against current code, please check and resend.
Current ASoC tree now has two commits:
commit 4eeed5f40354735c4e68e71904db528ed19c9cbb
Author: Souptick Joarder <[email protected]> Date: Sat Jan 9 09:15:01 2021 +0530
ASoC: soc-pcm: return correct -ERRNO in failure path
commit e91b65b36fde0690f1c694f17dd1b549295464a7
Author: Dan Carpenter <[email protected]> Date: Mon Jan 11 12:50:21 2021 +0300
ASoC: soc-pcm: Fix an uninitialized error code
..both set ret to non-zero, which I believe will throw a subsequent warning messagethat's not strictly related.
my fix was acked by [email protected], so I'm now confused what is the *correct* fix.
Colin
Mark Brown
maintainerQuoted 9 lines · Colin Ian King
Quoted 1 line · Mark Brown
This doesn't apply against current code, please check and resend.
..both set ret to non-zero, which I believe will throw a subsequent warning messagethat's not strictly related.
my fix was acked by [email protected], so I'm now confused what is the *correct* fix.
Quite probably yours in which case it'll need rebasing - IIRC I looked at the various patches at fairly separate times and didn't connect them, my workflow is based on queueing things for automated processing later so I won't always remember seeing something similar.
Quoted 19 lines · Colin Ian King
Quoted 9 lines · Mark Brown
Quoted 5 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the
This doesn't apply against current code, please check and resend.
Current ASoC tree now has two commits:
commit
4eeed5f40354735c4e68e71904db528ed19c9cbbAuthor: Souptick Joarder <[email protected]> Date: Sat Jan 9 09:15:01 2021 +0530ASoC: soc-pcm: return correct
-ERRNOin failure path
Quoted 8 lines
commit
e91b65b36fde0690f1c694f17dd1b549295464a7Author: Dan Carpenter <[email protected]> Date: Mon Jan 11 12:50:21 2021 +0300ASoC: soc-pcm: Fix an uninitialized error code
..both set ret to non-zero, which I believe will throw a subsequent warning messagethat's not strictly related.
My patch restored the original behavior. And I think that errors should return error codes. What you're saying is basically "Returning an error is a bug because it will trigger an error message in the caller". So then we have to have a debate about printks as a layering violation.
I don't like error messages generally, because I think they make the code messy. A lot of people put error messages for impossible things. Or if a kmalloc() fails or whatever. There are too many error messages which people add in an auto-pilot way without considering whether it's necessary.
But some people think, and maybe they're correct, that it's best if every function in the call tree prints a message. That way you can trace the error path easily.
regards,
dan carpenter
Quoted 40 lines · Dan Carpenter
Quoted 19 lines · Colin Ian King
Quoted 9 lines · Mark Brown
Quoted 5 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when attempting to start the BE fails because the FE is not started the error return variable ret is not initialized and garbage is returned. Fix this by setting it to 0 so the
This doesn't apply against current code, please check and resend.
Current ASoC tree now has two commits:
commit
4eeed5f40354735c4e68e71904db528ed19c9cbbAuthor: Souptick Joarder <[email protected]> Date: Sat Jan 9 09:15:01 2021 +0530ASoC: soc-pcm: return correct
-ERRNOin failure pathQuoted 8 lines
commit
e91b65b36fde0690f1c694f17dd1b549295464a7Author: Dan Carpenter <[email protected]> Date: Mon Jan 11 12:50:21 2021 +0300ASoC: soc-pcm: Fix an uninitialized error code
..both set ret to non-zero, which I believe will throw a subsequent warning messagethat's not strictly related.
My patch restored the original behavior. And I think that errors should return error codes. What you're saying is basically "Returning an error is a bug because it will trigger an error message in the caller". So then we have to have a debate about printks as a layering violation.
I don't like error messages generally, because I think they make the code messy. A lot of people put error messages for impossible things. Or if a
kmalloc()fails or whatever. There are too many error messages which people add in an auto-pilot way without considering whether it's necessary.
Quoted 3 lines
But some people think, and maybe they're correct, that it's best if every function in the call tree prints a message. That way you can trace the error path easily.
+1
Yep, good point, ignore my fix. Thanks Dan for your observations.
Quoted 4 lines
regards,
dan carpenter