All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-08 12:35 ` Colin King
  0 siblings, 0 replies; 18+ messages in thread
From: Colin King @ 2021-01-08 12:35 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 sound/soc/soc-pcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 481a4a25acb0..b787ce4ceb5a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -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;
 	}
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-08 12:35 ` Colin King
  0 siblings, 0 replies; 18+ messages in thread
From: Colin King @ 2021-01-08 12:35 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 sound/soc/soc-pcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 481a4a25acb0..b787ce4ceb5a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -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;
 	}
 
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re:[PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-08 12:35 ` Colin King
  (?)
@ 2021-01-11  9:56 ` 朱灿灿
  -1 siblings, 0 replies; 18+ messages in thread
From: 朱灿灿 @ 2021-01-11  9:56 UTC (permalink / raw)
  To: Colin King
  Cc: alsa-devel, linux-kernel, kernel-janitors, Takashi Iwai,
	Liam Girdwood, Mark Brown

Agree, thanks.


>
>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 <colin.king@canonical.com>
>---
> sound/soc/soc-pcm.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
>index 481a4a25acb0..b787ce4ceb5a 100644
>--- a/sound/soc/soc-pcm.c
>+++ b/sound/soc/soc-pcm.c
>@@ -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;
> 	}
> 
>-- 
>2.29.2
>





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-08 12:35 ` Colin King
@ 2021-01-11 16:35   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 16:35 UTC (permalink / raw)
  To: Colin King
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-11 16:35   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 16:35 UTC (permalink / raw)
  To: Colin King
  Cc: alsa-devel, 朱灿灿,
	kernel-janitors, Takashi Iwai, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-11 16:35   ` Mark Brown
@ 2021-01-11 17:07     ` Colin Ian King
  -1 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-11 17:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

On 11/01/2021 16:35, Mark Brown wrote:
> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-11 17:07     ` Colin Ian King
  0 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-11 17:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, 朱灿灿,
	kernel-janitors, Takashi Iwai, Liam Girdwood, linux-kernel

On 11/01/2021 16:35, Mark Brown wrote:
> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-11 17:07     ` Colin Ian King
@ 2021-01-11 17:09       ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 17:09 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

On Mon, Jan 11, 2021 at 05:07:46PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:

> > 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-11 17:09       ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 17:09 UTC (permalink / raw)
  To: Colin Ian King
  Cc: alsa-devel, 朱灿灿,
	kernel-janitors, Takashi Iwai, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

On Mon, Jan 11, 2021 at 05:07:46PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:

> > 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-11 16:35   ` Mark Brown
@ 2021-01-11 17:37     ` Colin Ian King
  -1 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-11 17:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

On 11/01/2021 16:35, Mark Brown wrote:
> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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 <jrdr.linux@gmail.com>
Date:   Sat Jan 9 09:15:01 2021 +0530

    ASoC: soc-pcm: return correct -ERRNO in failure path

commit e91b65b36fde0690f1c694f17dd1b549295464a7
Author: Dan Carpenter <dan.carpenter@oracle.com>
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 zhucancan@vivo.com, so I'm now confused what is the
*correct* fix.

Colin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-11 17:37     ` Colin Ian King
  0 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-11 17:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, 朱灿灿,
	kernel-janitors, Takashi Iwai, Liam Girdwood, linux-kernel

On 11/01/2021 16:35, Mark Brown wrote:
> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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 <jrdr.linux@gmail.com>
Date:   Sat Jan 9 09:15:01 2021 +0530

    ASoC: soc-pcm: return correct -ERRNO in failure path

commit e91b65b36fde0690f1c694f17dd1b549295464a7
Author: Dan Carpenter <dan.carpenter@oracle.com>
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 zhucancan@vivo.com, so I'm now confused what is the
*correct* fix.

Colin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-11 17:37     ` Colin Ian King
@ 2021-01-11 17:58       ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 17:58 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:

> > 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 zhucancan@vivo.com, 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-11 17:58       ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2021-01-11 17:58 UTC (permalink / raw)
  To: Colin Ian King
  Cc: alsa-devel, 朱灿灿,
	kernel-janitors, Takashi Iwai, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:

> > 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 zhucancan@vivo.com, 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-11 17:37     ` Colin Ian King
  (?)
@ 2021-01-12 10:22       ` Dan Carpenter
  -1 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2021-01-12 10:22 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:
> > On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> 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 <jrdr.linux@gmail.com>
> Date:   Sat Jan 9 09:15:01 2021 +0530
> 
>     ASoC: soc-pcm: return correct -ERRNO in failure path
> 
> commit e91b65b36fde0690f1c694f17dd1b549295464a7
> Author: Dan Carpenter <dan.carpenter@oracle.com>
> 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 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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-12 10:22       ` Dan Carpenter
  0 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2021-01-12 10:22 UTC (permalink / raw)
  To: Colin Ian King
  Cc: alsa-devel, kernel-janitors, 朱灿灿,
	Takashi Iwai, Liam Girdwood, Mark Brown, linux-kernel

On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:
> > On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> 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 <jrdr.linux@gmail.com>
> Date:   Sat Jan 9 09:15:01 2021 +0530
> 
>     ASoC: soc-pcm: return correct -ERRNO in failure path
> 
> commit e91b65b36fde0690f1c694f17dd1b549295464a7
> Author: Dan Carpenter <dan.carpenter@oracle.com>
> 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 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-12 10:22       ` Dan Carpenter
  0 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2021-01-12 10:22 UTC (permalink / raw)
  To: Colin Ian King
  Cc: alsa-devel, kernel-janitors, 朱灿灿,
	Takashi Iwai, Liam Girdwood, Mark Brown, linux-kernel

On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
> On 11/01/2021 16:35, Mark Brown wrote:
> > On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> 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 <jrdr.linux@gmail.com>
> Date:   Sat Jan 9 09:15:01 2021 +0530
> 
>     ASoC: soc-pcm: return correct -ERRNO in failure path
> 
> commit e91b65b36fde0690f1c694f17dd1b549295464a7
> Author: Dan Carpenter <dan.carpenter@oracle.com>
> 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 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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
  2021-01-12 10:22       ` Dan Carpenter
@ 2021-01-12 10:24         ` Colin Ian King
  -1 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-12 10:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	朱灿灿,
	alsa-devel, kernel-janitors, linux-kernel

On 12/01/2021 10:22, Dan Carpenter wrote:
> On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
>> On 11/01/2021 16:35, Mark Brown wrote:
>>> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> 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 <jrdr.linux@gmail.com>
>> Date:   Sat Jan 9 09:15:01 2021 +0530
>>
>>     ASoC: soc-pcm: return correct -ERRNO in failure path
>>
>> commit e91b65b36fde0690f1c694f17dd1b549295464a7
>> Author: Dan Carpenter <dan.carpenter@oracle.com>
>> 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 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.

+1

Yep, good point, ignore my fix. Thanks Dan for your observations.

> 
> regards,
> dan carpenter
> 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret
@ 2021-01-12 10:24         ` Colin Ian King
  0 siblings, 0 replies; 18+ messages in thread
From: Colin Ian King @ 2021-01-12 10:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: alsa-devel, kernel-janitors, 朱灿灿,
	Takashi Iwai, Liam Girdwood, Mark Brown, linux-kernel

On 12/01/2021 10:22, Dan Carpenter wrote:
> On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote:
>> On 11/01/2021 16:35, Mark Brown wrote:
>>> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote:
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> 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 <jrdr.linux@gmail.com>
>> Date:   Sat Jan 9 09:15:01 2021 +0530
>>
>>     ASoC: soc-pcm: return correct -ERRNO in failure path
>>
>> commit e91b65b36fde0690f1c694f17dd1b549295464a7
>> Author: Dan Carpenter <dan.carpenter@oracle.com>
>> 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 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.

+1

Yep, good point, ignore my fix. Thanks Dan for your observations.

> 
> regards,
> dan carpenter
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-01-12 10:25 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 12:35 [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret Colin King
2021-01-08 12:35 ` Colin King
2021-01-11  9:56 ` 朱灿灿
2021-01-11 16:35 ` [PATCH][next] " Mark Brown
2021-01-11 16:35   ` Mark Brown
2021-01-11 17:07   ` Colin Ian King
2021-01-11 17:07     ` Colin Ian King
2021-01-11 17:09     ` Mark Brown
2021-01-11 17:09       ` Mark Brown
2021-01-11 17:37   ` Colin Ian King
2021-01-11 17:37     ` Colin Ian King
2021-01-11 17:58     ` Mark Brown
2021-01-11 17:58       ` Mark Brown
2021-01-12 10:22     ` Dan Carpenter
2021-01-12 10:22       ` Dan Carpenter
2021-01-12 10:22       ` Dan Carpenter
2021-01-12 10:24       ` Colin Ian King
2021-01-12 10:24         ` Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.