All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  4:40 ` Christophe JAILLET
  0 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31  4:40 UTC (permalink / raw)
  To: perex, tiwai, arvind.yadav.cs, nicolas.ferre, broonie, garsilva,
	andriy.shevchenko, bhumirks
  Cc: alsa-devel, linux-kernel, kernel-janitors, Christophe JAILLET

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 30c64ab210d9..5ffefac2fa8f 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.11.0

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

* [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  4:40 ` Christophe JAILLET
  0 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31  4:40 UTC (permalink / raw)
  To: perex, tiwai, arvind.yadav.cs, nicolas.ferre, broonie, garsilva,
	andriy.shevchenko, bhumirks
  Cc: Christophe JAILLET, alsa-devel, kernel-janitors, linux-kernel

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 30c64ab210d9..5ffefac2fa8f 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.11.0


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

* [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  4:40 ` Christophe JAILLET
  0 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31  4:40 UTC (permalink / raw)
  To: perex, tiwai, arvind.yadav.cs, nicolas.ferre, broonie, garsilva,
	andriy.shevchenko, bhumirks
  Cc: Christophe JAILLET, alsa-devel, kernel-janitors, linux-kernel

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 30c64ab210d9..5ffefac2fa8f 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.11.0

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  4:40 ` Christophe JAILLET
  (?)
@ 2017-08-31  8:10   ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  8:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: perex, tiwai, arvind.yadav.cs, nicolas.ferre, broonie, garsilva,
	andriy.shevchenko, bhumirks, alsa-devel, kernel-janitors,
	linux-kernel

On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> If 'clk_prepare_enable()' fails, we must release some resources before
> returning. Add a new label in the existing error handling path and 'goto'
> there.
> 
> Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

And here is the fallout of the stupid, brainless "fixing" of issues
reported by static analysis tools.

This clk_prepare_enable will never fail. If it was going to fail, the
platform would never boot to a point were it is able to execute that
code. It is really annoying to have so much churn for absolutely 0
benefit.

Anyway,
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

> ---
>  sound/atmel/ac97c.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> index 30c64ab210d9..5ffefac2fa8f 100644
> --- a/sound/atmel/ac97c.c
> +++ b/sound/atmel/ac97c.c
> @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	}
>  	retval = clk_prepare_enable(pclk);
>  	if (retval)
> -		return retval;
> +		goto err_prepare_enable;
>  
>  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
>  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	snd_card_free(card);
>  err_snd_card_new:
>  	clk_disable_unprepare(pclk);
> +err_prepare_enable:
>  	clk_put(pclk);
>  	return retval;
>  }
> -- 
> 2.11.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  8:10   ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  8:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, kernel-janitors,
	nicolas.ferre, tiwai, broonie, garsilva, arvind.yadav.cs,
	bhumirks

On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> If 'clk_prepare_enable()' fails, we must release some resources before
> returning. Add a new label in the existing error handling path and 'goto'
> there.
> 
> Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

And here is the fallout of the stupid, brainless "fixing" of issues
reported by static analysis tools.

This clk_prepare_enable will never fail. If it was going to fail, the
platform would never boot to a point were it is able to execute that
code. It is really annoying to have so much churn for absolutely 0
benefit.

Anyway,
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

> ---
>  sound/atmel/ac97c.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> index 30c64ab210d9..5ffefac2fa8f 100644
> --- a/sound/atmel/ac97c.c
> +++ b/sound/atmel/ac97c.c
> @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	}
>  	retval = clk_prepare_enable(pclk);
>  	if (retval)
> -		return retval;
> +		goto err_prepare_enable;
>  
>  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
>  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	snd_card_free(card);
>  err_snd_card_new:
>  	clk_disable_unprepare(pclk);
> +err_prepare_enable:
>  	clk_put(pclk);
>  	return retval;
>  }
> -- 
> 2.11.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  8:10   ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  8:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, kernel-janitors,
	nicolas.ferre, tiwai, broonie, garsilva, arvind.yadav.cs,
	bhumirks

On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> If 'clk_prepare_enable()' fails, we must release some resources before
> returning. Add a new label in the existing error handling path and 'goto'
> there.
> 
> Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

And here is the fallout of the stupid, brainless "fixing" of issues
reported by static analysis tools.

This clk_prepare_enable will never fail. If it was going to fail, the
platform would never boot to a point were it is able to execute that
code. It is really annoying to have so much churn for absolutely 0
benefit.

Anyway,
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

> ---
>  sound/atmel/ac97c.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> index 30c64ab210d9..5ffefac2fa8f 100644
> --- a/sound/atmel/ac97c.c
> +++ b/sound/atmel/ac97c.c
> @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	}
>  	retval = clk_prepare_enable(pclk);
>  	if (retval)
> -		return retval;
> +		goto err_prepare_enable;
>  
>  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
>  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
>  	snd_card_free(card);
>  err_snd_card_new:
>  	clk_disable_unprepare(pclk);
> +err_prepare_enable:
>  	clk_put(pclk);
>  	return retval;
>  }
> -- 
> 2.11.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  8:10   ` [alsa-devel] " Alexandre Belloni
  (?)
@ 2017-08-31  8:23     ` Julia Lawall
  -1 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31  8:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Christophe JAILLET, perex, tiwai, arvind.yadav.cs, nicolas.ferre,
	broonie, garsilva, andriy.shevchenko, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > If 'clk_prepare_enable()' fails, we must release some resources before
> > returning. Add a new label in the existing error handling path and 'goto'
> > there.
> >
> > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.
>
> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

Would it be more productive to put the code back like it was before, ie no
return value and no check, and add a comment to the definition of
clk_prepare_enable indicating that there are many case where the call
cannot fail?  Grepping through the code suggests that it is about 50-50 on
checking the return value or not doing so, which might suggest that
checking the value is often not required.

julia

>
> Anyway,
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>
> > ---
> >  sound/atmel/ac97c.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> > index 30c64ab210d9..5ffefac2fa8f 100644
> > --- a/sound/atmel/ac97c.c
> > +++ b/sound/atmel/ac97c.c
> > @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	}
> >  	retval = clk_prepare_enable(pclk);
> >  	if (retval)
> > -		return retval;
> > +		goto err_prepare_enable;
> >
> >  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
> >  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> > @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	snd_card_free(card);
> >  err_snd_card_new:
> >  	clk_disable_unprepare(pclk);
> > +err_prepare_enable:
> >  	clk_put(pclk);
> >  	return retval;
> >  }
> > --
> > 2.11.0
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  8:23     ` Julia Lawall
  0 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31  8:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, garsilva,
	kernel-janitors, nicolas.ferre, tiwai, broonie,
	Christophe JAILLET, arvind.yadav.cs, bhumirks



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > If 'clk_prepare_enable()' fails, we must release some resources before
> > returning. Add a new label in the existing error handling path and 'goto'
> > there.
> >
> > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.
>
> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

Would it be more productive to put the code back like it was before, ie no
return value and no check, and add a comment to the definition of
clk_prepare_enable indicating that there are many case where the call
cannot fail?  Grepping through the code suggests that it is about 50-50 on
checking the return value or not doing so, which might suggest that
checking the value is often not required.

julia

>
> Anyway,
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>
> > ---
> >  sound/atmel/ac97c.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> > index 30c64ab210d9..5ffefac2fa8f 100644
> > --- a/sound/atmel/ac97c.c
> > +++ b/sound/atmel/ac97c.c
> > @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	}
> >  	retval = clk_prepare_enable(pclk);
> >  	if (retval)
> > -		return retval;
> > +		goto err_prepare_enable;
> >
> >  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
> >  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> > @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	snd_card_free(card);
> >  err_snd_card_new:
> >  	clk_disable_unprepare(pclk);
> > +err_prepare_enable:
> >  	clk_put(pclk);
> >  	return retval;
> >  }
> > --
> > 2.11.0
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  8:23     ` Julia Lawall
  0 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31  8:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, garsilva,
	kernel-janitors, nicolas.ferre, tiwai, broonie,
	Christophe JAILLET, arvind.yadav.cs, bhumirks



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > If 'clk_prepare_enable()' fails, we must release some resources before
> > returning. Add a new label in the existing error handling path and 'goto'
> > there.
> >
> > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.
>
> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

Would it be more productive to put the code back like it was before, ie no
return value and no check, and add a comment to the definition of
clk_prepare_enable indicating that there are many case where the call
cannot fail?  Grepping through the code suggests that it is about 50-50 on
checking the return value or not doing so, which might suggest that
checking the value is often not required.

julia

>
> Anyway,
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>
> > ---
> >  sound/atmel/ac97c.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> > index 30c64ab210d9..5ffefac2fa8f 100644
> > --- a/sound/atmel/ac97c.c
> > +++ b/sound/atmel/ac97c.c
> > @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	}
> >  	retval = clk_prepare_enable(pclk);
> >  	if (retval)
> > -		return retval;
> > +		goto err_prepare_enable;
> >
> >  	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
> >  			      SNDRV_DEFAULT_STR1, THIS_MODULE,
> > @@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> >  	snd_card_free(card);
> >  err_snd_card_new:
> >  	clk_disable_unprepare(pclk);
> > +err_prepare_enable:
> >  	clk_put(pclk);
> >  	return retval;
> >  }
> > --
> > 2.11.0
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  8:23     ` [alsa-devel] " Julia Lawall
  (?)
@ 2017-08-31  9:04       ` Andy Shevchenko
  -1 siblings, 0 replies; 55+ messages in thread
From: Andy Shevchenko @ 2017-08-31  9:04 UTC (permalink / raw)
  To: Julia Lawall, Alexandre Belloni
  Cc: Christophe JAILLET, perex, tiwai, arvind.yadav.cs, nicolas.ferre,
	broonie, garsilva, bhumirks, alsa-devel, kernel-janitors,
	linux-kernel

On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources
> > > before
> > > returning. Add a new label in the existing error handling path and
> > > 'goto'
> > > there.
> > > 
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of
> > > clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> > 
> > This clk_prepare_enable will never fail. If it was going to fail,
> > the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before,
> ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-
> 50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.

I didn't look into the code, though speculating it might be the case
when CLK framework is not enabled, though many drivers are dependent to
it, so, it would never fail in such cases. Nevertheless there might be
other cases for CLK API to fail.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:04       ` Andy Shevchenko
  0 siblings, 0 replies; 55+ messages in thread
From: Andy Shevchenko @ 2017-08-31  9:04 UTC (permalink / raw)
  To: Julia Lawall, Alexandre Belloni
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, tiwai, broonie, Christophe JAILLET,
	arvind.yadav.cs, bhumirks

On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources
> > > before
> > > returning. Add a new label in the existing error handling path and
> > > 'goto'
> > > there.
> > > 
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of
> > > clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> > 
> > This clk_prepare_enable will never fail. If it was going to fail,
> > the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before,
> ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-
> 50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.

I didn't look into the code, though speculating it might be the case
when CLK framework is not enabled, though many drivers are dependent to
it, so, it would never fail in such cases. Nevertheless there might be
other cases for CLK API to fail.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:04       ` Andy Shevchenko
  0 siblings, 0 replies; 55+ messages in thread
From: Andy Shevchenko @ 2017-08-31  9:04 UTC (permalink / raw)
  To: Julia Lawall, Alexandre Belloni
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, tiwai, broonie, Christophe JAILLET,
	arvind.yadav.cs, bhumirks

On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources
> > > before
> > > returning. Add a new label in the existing error handling path and
> > > 'goto'
> > > there.
> > > 
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of
> > > clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> > 
> > This clk_prepare_enable will never fail. If it was going to fail,
> > the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before,
> ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-
> 50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.

I didn't look into the code, though speculating it might be the case
when CLK framework is not enabled, though many drivers are dependent to
it, so, it would never fail in such cases. Nevertheless there might be
other cases for CLK API to fail.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  9:04       ` [alsa-devel] " Andy Shevchenko
@ 2017-08-31  9:35         ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Julia Lawall, Christophe JAILLET, perex, tiwai, arvind.yadav.cs,
	nicolas.ferre, broonie, garsilva, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > 
> > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > 
> > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > If 'clk_prepare_enable()' fails, we must release some resources
> > > > before
> > > > returning. Add a new label in the existing error handling path and
> > > > 'goto'
> > > > there.
> > > > 
> > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of
> > > > clk_prepare_enable.")
> > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > 
> > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > reported by static analysis tools.
> > > 
> > > This clk_prepare_enable will never fail. If it was going to fail,
> > > the
> > > platform would never boot to a point were it is able to execute that
> > > code. It is really annoying to have so much churn for absolutely 0
> > > benefit.
> > 
> > Would it be more productive to put the code back like it was before,
> > ie no
> > return value and no check, and add a comment to the definition of
> > clk_prepare_enable indicating that there are many case where the call
> > cannot fail?  Grepping through the code suggests that it is about 50-
> > 50 on
> > checking the return value or not doing so, which might suggest that
> > checking the value is often not required.
> 
> I didn't look into the code, though speculating it might be the case
> when CLK framework is not enabled, though many drivers are dependent to
> it, so, it would never fail in such cases.

It is not the case, it would return 0. Anyway, this will not happen
because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
which selects COMMON_CLK.

> Nevertheless there might be
> other cases for CLK API to fail.
> 

The only case would be for a clock to be enabled without being prepared
and this will never happen because clk_prepare_enable is used.

This call will just never fail.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:35         ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Julia Lawall, Christophe JAILLET, perex, tiwai, arvind.yadav.cs,
	nicolas.ferre, broonie, garsilva, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > 
> > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > 
> > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > If 'clk_prepare_enable()' fails, we must release some resources
> > > > before
> > > > returning. Add a new label in the existing error handling path and
> > > > 'goto'
> > > > there.
> > > > 
> > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of
> > > > clk_prepare_enable.")
> > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > 
> > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > reported by static analysis tools.
> > > 
> > > This clk_prepare_enable will never fail. If it was going to fail,
> > > the
> > > platform would never boot to a point were it is able to execute that
> > > code. It is really annoying to have so much churn for absolutely 0
> > > benefit.
> > 
> > Would it be more productive to put the code back like it was before,
> > ie no
> > return value and no check, and add a comment to the definition of
> > clk_prepare_enable indicating that there are many case where the call
> > cannot fail?  Grepping through the code suggests that it is about 50-
> > 50 on
> > checking the return value or not doing so, which might suggest that
> > checking the value is often not required.
> 
> I didn't look into the code, though speculating it might be the case
> when CLK framework is not enabled, though many drivers are dependent to
> it, so, it would never fail in such cases.

It is not the case, it would return 0. Anyway, this will not happen
because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
which selects COMMON_CLK.

> Nevertheless there might be
> other cases for CLK API to fail.
> 

The only case would be for a clock to be enabled without being prepared
and this will never happen because clk_prepare_enable is used.

This call will just never fail.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  9:35         ` Alexandre Belloni
@ 2017-08-31  9:38           ` Andy Shevchenko
  -1 siblings, 0 replies; 55+ messages in thread
From: Andy Shevchenko @ 2017-08-31  9:38 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, Christophe JAILLET, perex, tiwai, arvind.yadav.cs,
	nicolas.ferre, broonie, garsilva, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On Thu, 2017-08-31 at 11:35 +0200, Alexandre Belloni wrote:
> On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> > On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > 

> > I didn't look into the code, though speculating it might be the case
> > when CLK framework is not enabled, though many drivers are dependent
> > to
> > it, so, it would never fail in such cases.
> 
> It is not the case, it would return 0. Anyway, this will not happen
> because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
> which selects COMMON_CLK.
> 
> > Nevertheless there might be
> > other cases for CLK API to fail.
> > 
> 
> The only case would be for a clock to be enabled without being
> prepared
> and this will never happen because clk_prepare_enable is used.
> 
> This call will just never fail.

So, then this is a bug of CLK API per se to have a prototype to return
int, right?

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:38           ` Andy Shevchenko
  0 siblings, 0 replies; 55+ messages in thread
From: Andy Shevchenko @ 2017-08-31  9:38 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, Christophe JAILLET, perex, tiwai, arvind.yadav.cs,
	nicolas.ferre, broonie, garsilva, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On Thu, 2017-08-31 at 11:35 +0200, Alexandre Belloni wrote:
> On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> > On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > 

> > I didn't look into the code, though speculating it might be the case
> > when CLK framework is not enabled, though many drivers are dependent
> > to
> > it, so, it would never fail in such cases.
> 
> It is not the case, it would return 0. Anyway, this will not happen
> because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
> which selects COMMON_CLK.
> 
> > Nevertheless there might be
> > other cases for CLK API to fail.
> > 
> 
> The only case would be for a clock to be enabled without being
> prepared
> and this will never happen because clk_prepare_enable is used.
> 
> This call will just never fail.

So, then this is a bug of CLK API per se to have a prototype to return
int, right?

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  8:23     ` [alsa-devel] " Julia Lawall
  (?)
@ 2017-08-31  9:56       ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:56 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Christophe JAILLET, perex, tiwai, arvind.yadav.cs, nicolas.ferre,
	broonie, garsilva, andriy.shevchenko, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> 
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > returning. Add a new label in the existing error handling path and 'goto'
> > > there.
> > >
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> >
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before, ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.
> 

I'd say that it is often useless to test the value. I don't have any
problem with the test as it doesn't add much (at least it doesn't print
an error message). So it may stays here. What I'm really unhappy about
is people sending hundreds of similar, autogenerated patches to
maintainers without actually putting any thought into them. That put all
the burden on the maintainers to weed out the incorrect patches.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:56       ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:56 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, garsilva,
	kernel-janitors, nicolas.ferre, tiwai, broonie,
	Christophe JAILLET, arvind.yadav.cs, bhumirks

On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> 
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > returning. Add a new label in the existing error handling path and 'goto'
> > > there.
> > >
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> >
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before, ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.
> 

I'd say that it is often useless to test the value. I don't have any
problem with the test as it doesn't add much (at least it doesn't print
an error message). So it may stays here. What I'm really unhappy about
is people sending hundreds of similar, autogenerated patches to
maintainers without actually putting any thought into them. That put all
the burden on the maintainers to weed out the incorrect patches.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:56       ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:56 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, garsilva,
	kernel-janitors, nicolas.ferre, tiwai, broonie,
	Christophe JAILLET, arvind.yadav.cs, bhumirks

On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> 
> 
> On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> 
> > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > returning. Add a new label in the existing error handling path and 'goto'
> > > there.
> > >
> > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> >
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> Would it be more productive to put the code back like it was before, ie no
> return value and no check, and add a comment to the definition of
> clk_prepare_enable indicating that there are many case where the call
> cannot fail?  Grepping through the code suggests that it is about 50-50 on
> checking the return value or not doing so, which might suggest that
> checking the value is often not required.
> 

I'd say that it is often useless to test the value. I don't have any
problem with the test as it doesn't add much (at least it doesn't print
an error message). So it may stays here. What I'm really unhappy about
is people sending hundreds of similar, autogenerated patches to
maintainers without actually putting any thought into them. That put all
the burden on the maintainers to weed out the incorrect patches.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  9:38           ` Andy Shevchenko
  (?)
@ 2017-08-31  9:57             ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Julia Lawall, Christophe JAILLET, perex, tiwai, arvind.yadav.cs,
	nicolas.ferre, broonie, garsilva, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

On 31/08/2017 at 12:38:17 +0300, Andy Shevchenko wrote:
> On Thu, 2017-08-31 at 11:35 +0200, Alexandre Belloni wrote:
> > On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> > > On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > > > 
> > > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > > 
> > > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > > 
> 
> > > I didn't look into the code, though speculating it might be the case
> > > when CLK framework is not enabled, though many drivers are dependent
> > > to
> > > it, so, it would never fail in such cases.
> > 
> > It is not the case, it would return 0. Anyway, this will not happen
> > because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
> > which selects COMMON_CLK.
> > 
> > > Nevertheless there might be
> > > other cases for CLK API to fail.
> > > 
> > 
> > The only case would be for a clock to be enabled without being
> > prepared
> > and this will never happen because clk_prepare_enable is used.
> > 
> > This call will just never fail.
> 
> So, then this is a bug of CLK API per se to have a prototype to return
> int, right?
> 

No because it may fail on other platforms.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:57             ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, tiwai, Julia Lawall, broonie, Christophe JAILLET,
	arvind.yadav.cs, bhumirks

On 31/08/2017 at 12:38:17 +0300, Andy Shevchenko wrote:
> On Thu, 2017-08-31 at 11:35 +0200, Alexandre Belloni wrote:
> > On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> > > On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > > > 
> > > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > > 
> > > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > > 
> 
> > > I didn't look into the code, though speculating it might be the case
> > > when CLK framework is not enabled, though many drivers are dependent
> > > to
> > > it, so, it would never fail in such cases.
> > 
> > It is not the case, it would return 0. Anyway, this will not happen
> > because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
> > which selects COMMON_CLK.
> > 
> > > Nevertheless there might be
> > > other cases for CLK API to fail.
> > > 
> > 
> > The only case would be for a clock to be enabled without being
> > prepared
> > and this will never happen because clk_prepare_enable is used.
> > 
> > This call will just never fail.
> 
> So, then this is a bug of CLK API per se to have a prototype to return
> int, right?
> 

No because it may fail on other platforms.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31  9:57             ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31  9:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, tiwai, Julia Lawall, broonie, Christophe JAILLET,
	arvind.yadav.cs, bhumirks

On 31/08/2017 at 12:38:17 +0300, Andy Shevchenko wrote:
> On Thu, 2017-08-31 at 11:35 +0200, Alexandre Belloni wrote:
> > On 31/08/2017 at 12:04:03 +0300, Andy Shevchenko wrote:
> > > On Thu, 2017-08-31 at 10:23 +0200, Julia Lawall wrote:
> > > > 
> > > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > > 
> > > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > > 
> 
> > > I didn't look into the code, though speculating it might be the case
> > > when CLK framework is not enabled, though many drivers are dependent
> > > to
> > > it, so, it would never fail in such cases.
> > 
> > It is not the case, it would return 0. Anyway, this will not happen
> > because that driver depends on ARCH_AT91 which selects COMMON_CLK_AT91
> > which selects COMMON_CLK.
> > 
> > > Nevertheless there might be
> > > other cases for CLK API to fail.
> > > 
> > 
> > The only case would be for a clock to be enabled without being
> > prepared
> > and this will never happen because clk_prepare_enable is used.
> > 
> > This call will just never fail.
> 
> So, then this is a bug of CLK API per se to have a prototype to return
> int, right?
> 

No because it may fail on other platforms.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  9:56       ` [alsa-devel] " Alexandre Belloni
  (?)
@ 2017-08-31 10:13         ` Takashi Iwai
  -1 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:13 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 11:56:16 +0200,
Alexandre Belloni wrote:
> 
> On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > 
> > 
> > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > 
> > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > there.
> > > >
> > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > >
> > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > reported by static analysis tools.
> > >
> > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > platform would never boot to a point were it is able to execute that
> > > code. It is really annoying to have so much churn for absolutely 0
> > > benefit.
> > 
> > Would it be more productive to put the code back like it was before, ie no
> > return value and no check, and add a comment to the definition of
> > clk_prepare_enable indicating that there are many case where the call
> > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > checking the return value or not doing so, which might suggest that
> > checking the value is often not required.
> > 
> 
> I'd say that it is often useless to test the value. I don't have any
> problem with the test as it doesn't add much (at least it doesn't print
> an error message). So it may stays here. What I'm really unhappy about
> is people sending hundreds of similar, autogenerated patches to
> maintainers without actually putting any thought into them. That put all
> the burden on the maintainers to weed out the incorrect patches.

I share your concerns, e.g. the burden of maintenance is a problem.

But in this case, the original code looks really buggy.  If the test
doesn't make sense, don't test it but give a proper comment from the
beginning.  Instead, the current code does check the return value yet
with the incorrect error path.

The proposed "fix" won't change any actual behavior in practice, which
is useless, yes.  (And this is good -- at least it's safe to apply :)
OTOH, the semantics is a different question, and the patch corrects
it, which isn't so stupid, IMO.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:13         ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:13 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	Julia Lawall, broonie, garsilva, Christophe JAILLET,
	arvind.yadav.cs, andriy.shevchenko, bhumirks

On Thu, 31 Aug 2017 11:56:16 +0200,
Alexandre Belloni wrote:
> 
> On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > 
> > 
> > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > 
> > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > there.
> > > >
> > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > >
> > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > reported by static analysis tools.
> > >
> > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > platform would never boot to a point were it is able to execute that
> > > code. It is really annoying to have so much churn for absolutely 0
> > > benefit.
> > 
> > Would it be more productive to put the code back like it was before, ie no
> > return value and no check, and add a comment to the definition of
> > clk_prepare_enable indicating that there are many case where the call
> > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > checking the return value or not doing so, which might suggest that
> > checking the value is often not required.
> > 
> 
> I'd say that it is often useless to test the value. I don't have any
> problem with the test as it doesn't add much (at least it doesn't print
> an error message). So it may stays here. What I'm really unhappy about
> is people sending hundreds of similar, autogenerated patches to
> maintainers without actually putting any thought into them. That put all
> the burden on the maintainers to weed out the incorrect patches.

I share your concerns, e.g. the burden of maintenance is a problem.

But in this case, the original code looks really buggy.  If the test
doesn't make sense, don't test it but give a proper comment from the
beginning.  Instead, the current code does check the return value yet
with the incorrect error path.

The proposed "fix" won't change any actual behavior in practice, which
is useless, yes.  (And this is good -- at least it's safe to apply :)
OTOH, the semantics is a different question, and the patch corrects
it, which isn't so stupid, IMO.


thanks,

Takashi

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:13         ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:13 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	Julia Lawall, broonie, garsilva, Christophe JAILLET,
	arvind.yadav.cs, andriy.shevchenko, bhumirks

On Thu, 31 Aug 2017 11:56:16 +0200,
Alexandre Belloni wrote:
> 
> On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > 
> > 
> > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > 
> > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > there.
> > > >
> > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > >
> > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > reported by static analysis tools.
> > >
> > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > platform would never boot to a point were it is able to execute that
> > > code. It is really annoying to have so much churn for absolutely 0
> > > benefit.
> > 
> > Would it be more productive to put the code back like it was before, ie no
> > return value and no check, and add a comment to the definition of
> > clk_prepare_enable indicating that there are many case where the call
> > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > checking the return value or not doing so, which might suggest that
> > checking the value is often not required.
> > 
> 
> I'd say that it is often useless to test the value. I don't have any
> problem with the test as it doesn't add much (at least it doesn't print
> an error message). So it may stays here. What I'm really unhappy about
> is people sending hundreds of similar, autogenerated patches to
> maintainers without actually putting any thought into them. That put all
> the burden on the maintainers to weed out the incorrect patches.

I share your concerns, e.g. the burden of maintenance is a problem.

But in this case, the original code looks really buggy.  If the test
doesn't make sense, don't test it but give a proper comment from the
beginning.  Instead, the current code does check the return value yet
with the incorrect error path.

The proposed "fix" won't change any actual behavior in practice, which
is useless, yes.  (And this is good -- at least it's safe to apply :)
OTOH, the semantics is a different question, and the patch corrects
it, which isn't so stupid, IMO.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31  8:10   ` [alsa-devel] " Alexandre Belloni
  (?)
@ 2017-08-31 10:19     ` Mark Brown
  -1 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:19 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Christophe JAILLET, perex, tiwai, arvind.yadav.cs, nicolas.ferre,
	garsilva, andriy.shevchenko, bhumirks, alsa-devel,
	kernel-janitors, linux-kernel

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

On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:

> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.

> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

It may currently be the case that the SoCs you're looking at happen to
make this clock essential but that doesn't mean that it's not going to
be different in some future SoC, nor that we can't have a software bug
that this will detect.  Being consistent with our error checking also
means that we can spot places where it might practically be a problem
more easily, it's even easier if the error checking is there first time
but it's still worth it to go back later.

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

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:19     ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:19 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, kernel-janitors,
	Christophe JAILLET, nicolas.ferre, tiwai, garsilva,
	arvind.yadav.cs, bhumirks

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

On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:

> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.

> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

It may currently be the case that the SoCs you're looking at happen to
make this clock essential but that doesn't mean that it's not going to
be different in some future SoC, nor that we can't have a software bug
that this will detect.  Being consistent with our error checking also
means that we can spot places where it might practically be a problem
more easily, it's even easier if the error checking is there first time
but it's still worth it to go back later.

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

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:19     ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:19 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, andriy.shevchenko, linux-kernel, kernel-janitors,
	Christophe JAILLET, nicolas.ferre, tiwai, garsilva,
	arvind.yadav.cs, bhumirks


[-- Attachment #1.1: Type: text/plain, Size: 867 bytes --]

On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:

> And here is the fallout of the stupid, brainless "fixing" of issues
> reported by static analysis tools.

> This clk_prepare_enable will never fail. If it was going to fail, the
> platform would never boot to a point were it is able to execute that
> code. It is really annoying to have so much churn for absolutely 0
> benefit.

It may currently be the case that the SoCs you're looking at happen to
make this clock essential but that doesn't mean that it's not going to
be different in some future SoC, nor that we can't have a software bug
that this will detect.  Being consistent with our error checking also
means that we can spot places where it might practically be a problem
more easily, it's even easier if the error checking is there first time
but it's still worth it to go back later.

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:13         ` [alsa-devel] " Takashi Iwai
@ 2017-08-31 10:19           ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31 10:19 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On 31/08/2017 at 12:13:00 +0200, Takashi Iwai wrote:
> On Thu, 31 Aug 2017 11:56:16 +0200,
> Alexandre Belloni wrote:
> > 
> > On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > > there.
> > > > >
> > > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > >
> > > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > > reported by static analysis tools.
> > > >
> > > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > > platform would never boot to a point were it is able to execute that
> > > > code. It is really annoying to have so much churn for absolutely 0
> > > > benefit.
> > > 
> > > Would it be more productive to put the code back like it was before, ie no
> > > return value and no check, and add a comment to the definition of
> > > clk_prepare_enable indicating that there are many case where the call
> > > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > > checking the return value or not doing so, which might suggest that
> > > checking the value is often not required.
> > > 
> > 
> > I'd say that it is often useless to test the value. I don't have any
> > problem with the test as it doesn't add much (at least it doesn't print
> > an error message). So it may stays here. What I'm really unhappy about
> > is people sending hundreds of similar, autogenerated patches to
> > maintainers without actually putting any thought into them. That put all
> > the burden on the maintainers to weed out the incorrect patches.
> 
> I share your concerns, e.g. the burden of maintenance is a problem.
> 
> But in this case, the original code looks really buggy.  If the test
> doesn't make sense, don't test it but give a proper comment from the
> beginning.  Instead, the current code does check the return value yet
> with the incorrect error path.
> 
> The proposed "fix" won't change any actual behavior in practice, which
> is useless, yes.  (And this is good -- at least it's safe to apply :)
> OTOH, the semantics is a different question, and the patch corrects
> it, which isn't so stupid, IMO.
> 

Agreed, I'm complaining about the original patch adding the test, not
the current patch that fixes it.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:19           ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31 10:19 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On 31/08/2017 at 12:13:00 +0200, Takashi Iwai wrote:
> On Thu, 31 Aug 2017 11:56:16 +0200,
> Alexandre Belloni wrote:
> > 
> > On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > > there.
> > > > >
> > > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > >
> > > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > > reported by static analysis tools.
> > > >
> > > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > > platform would never boot to a point were it is able to execute that
> > > > code. It is really annoying to have so much churn for absolutely 0
> > > > benefit.
> > > 
> > > Would it be more productive to put the code back like it was before, ie no
> > > return value and no check, and add a comment to the definition of
> > > clk_prepare_enable indicating that there are many case where the call
> > > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > > checking the return value or not doing so, which might suggest that
> > > checking the value is often not required.
> > > 
> > 
> > I'd say that it is often useless to test the value. I don't have any
> > problem with the test as it doesn't add much (at least it doesn't print
> > an error message). So it may stays here. What I'm really unhappy about
> > is people sending hundreds of similar, autogenerated patches to
> > maintainers without actually putting any thought into them. That put all
> > the burden on the maintainers to weed out the incorrect patches.
> 
> I share your concerns, e.g. the burden of maintenance is a problem.
> 
> But in this case, the original code looks really buggy.  If the test
> doesn't make sense, don't test it but give a proper comment from the
> beginning.  Instead, the current code does check the return value yet
> with the incorrect error path.
> 
> The proposed "fix" won't change any actual behavior in practice, which
> is useless, yes.  (And this is good -- at least it's safe to apply :)
> OTOH, the semantics is a different question, and the patch corrects
> it, which isn't so stupid, IMO.
> 

Agreed, I'm complaining about the original patch adding the test, not
the current patch that fixes it.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:13         ` [alsa-devel] " Takashi Iwai
  (?)
@ 2017-08-31 10:23           ` Takashi Iwai
  -1 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:13:00 +0200,
Takashi Iwai wrote:
> 
> On Thu, 31 Aug 2017 11:56:16 +0200,
> Alexandre Belloni wrote:
> > 
> > On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > > there.
> > > > >
> > > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > >
> > > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > > reported by static analysis tools.
> > > >
> > > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > > platform would never boot to a point were it is able to execute that
> > > > code. It is really annoying to have so much churn for absolutely 0
> > > > benefit.
> > > 
> > > Would it be more productive to put the code back like it was before, ie no
> > > return value and no check, and add a comment to the definition of
> > > clk_prepare_enable indicating that there are many case where the call
> > > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > > checking the return value or not doing so, which might suggest that
> > > checking the value is often not required.
> > > 
> > 
> > I'd say that it is often useless to test the value. I don't have any
> > problem with the test as it doesn't add much (at least it doesn't print
> > an error message). So it may stays here. What I'm really unhappy about
> > is people sending hundreds of similar, autogenerated patches to
> > maintainers without actually putting any thought into them. That put all
> > the burden on the maintainers to weed out the incorrect patches.
> 
> I share your concerns, e.g. the burden of maintenance is a problem.
> 
> But in this case, the original code looks really buggy.  If the test
> doesn't make sense, don't test it but give a proper comment from the
> beginning.  Instead, the current code does check the return value yet
> with the incorrect error path.
> 
> The proposed "fix" won't change any actual behavior in practice, which
> is useless, yes.  (And this is good -- at least it's safe to apply :)
> OTOH, the semantics is a different question, and the patch corrects
> it, which isn't so stupid, IMO.

Ah, wait, now I see your point.  It was introduced by the very recent
patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
while it isn't).  That patch looks indeed fishy.  The change in
atmel_ac97c_resume() is also bad.

So, I'd prefer reverting the wrong commit instead, and leave some
comment about the uselessness of clk_prepare_enable() return value
check.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:23           ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:13:00 +0200,
Takashi Iwai wrote:
> 
> On Thu, 31 Aug 2017 11:56:16 +0200,
> Alexandre Belloni wrote:
> > 
> > On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > > there.
> > > > >
> > > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > >
> > > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > > reported by static analysis tools.
> > > >
> > > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > > platform would never boot to a point were it is able to execute that
> > > > code. It is really annoying to have so much churn for absolutely 0
> > > > benefit.
> > > 
> > > Would it be more productive to put the code back like it was before, ie no
> > > return value and no check, and add a comment to the definition of
> > > clk_prepare_enable indicating that there are many case where the call
> > > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > > checking the return value or not doing so, which might suggest that
> > > checking the value is often not required.
> > > 
> > 
> > I'd say that it is often useless to test the value. I don't have any
> > problem with the test as it doesn't add much (at least it doesn't print
> > an error message). So it may stays here. What I'm really unhappy about
> > is people sending hundreds of similar, autogenerated patches to
> > maintainers without actually putting any thought into them. That put all
> > the burden on the maintainers to weed out the incorrect patches.
> 
> I share your concerns, e.g. the burden of maintenance is a problem.
> 
> But in this case, the original code looks really buggy.  If the test
> doesn't make sense, don't test it but give a proper comment from the
> beginning.  Instead, the current code does check the return value yet
> with the incorrect error path.
> 
> The proposed "fix" won't change any actual behavior in practice, which
> is useless, yes.  (And this is good -- at least it's safe to apply :)
> OTOH, the semantics is a different question, and the patch corrects
> it, which isn't so stupid, IMO.

Ah, wait, now I see your point.  It was introduced by the very recent
patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
while it isn't).  That patch looks indeed fishy.  The change in
atmel_ac97c_resume() is also bad.

So, I'd prefer reverting the wrong commit instead, and leave some
comment about the uselessness of clk_prepare_enable() return value
check.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:23           ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:23 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Julia Lawall, alsa-devel, garsilva, arvind.yadav.cs, bhumirks,
	broonie, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:13:00 +0200,
Takashi Iwai wrote:
> 
> On Thu, 31 Aug 2017 11:56:16 +0200,
> Alexandre Belloni wrote:
> > 
> > On 31/08/2017 at 10:23:19 +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Thu, 31 Aug 2017, Alexandre Belloni wrote:
> > > 
> > > > On 31/08/2017 at 06:40:42 +0200, Christophe JAILLET wrote:
> > > > > If 'clk_prepare_enable()' fails, we must release some resources before
> > > > > returning. Add a new label in the existing error handling path and 'goto'
> > > > > there.
> > > > >
> > > > > Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
> > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > >
> > > > And here is the fallout of the stupid, brainless "fixing" of issues
> > > > reported by static analysis tools.
> > > >
> > > > This clk_prepare_enable will never fail. If it was going to fail, the
> > > > platform would never boot to a point were it is able to execute that
> > > > code. It is really annoying to have so much churn for absolutely 0
> > > > benefit.
> > > 
> > > Would it be more productive to put the code back like it was before, ie no
> > > return value and no check, and add a comment to the definition of
> > > clk_prepare_enable indicating that there are many case where the call
> > > cannot fail?  Grepping through the code suggests that it is about 50-50 on
> > > checking the return value or not doing so, which might suggest that
> > > checking the value is often not required.
> > > 
> > 
> > I'd say that it is often useless to test the value. I don't have any
> > problem with the test as it doesn't add much (at least it doesn't print
> > an error message). So it may stays here. What I'm really unhappy about
> > is people sending hundreds of similar, autogenerated patches to
> > maintainers without actually putting any thought into them. That put all
> > the burden on the maintainers to weed out the incorrect patches.
> 
> I share your concerns, e.g. the burden of maintenance is a problem.
> 
> But in this case, the original code looks really buggy.  If the test
> doesn't make sense, don't test it but give a proper comment from the
> beginning.  Instead, the current code does check the return value yet
> with the incorrect error path.
> 
> The proposed "fix" won't change any actual behavior in practice, which
> is useless, yes.  (And this is good -- at least it's safe to apply :)
> OTOH, the semantics is a different question, and the patch corrects
> it, which isn't so stupid, IMO.

Ah, wait, now I see your point.  It was introduced by the very recent
patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
while it isn't).  That patch looks indeed fishy.  The change in
atmel_ac97c_resume() is also bad.

So, I'd prefer reverting the wrong commit instead, and leave some
comment about the uselessness of clk_prepare_enable() return value
check.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:19     ` [alsa-devel] " Mark Brown
  (?)
@ 2017-08-31 10:31       ` Takashi Iwai
  -1 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:31 UTC (permalink / raw)
  To: Mark Brown
  Cc: Alexandre Belloni, alsa-devel, garsilva, arvind.yadav.cs,
	bhumirks, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:19:03 +0200,
Mark Brown wrote:
> 
> On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:
> 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> 
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> It may currently be the case that the SoCs you're looking at happen to
> make this clock essential but that doesn't mean that it's not going to
> be different in some future SoC, nor that we can't have a software bug
> that this will detect.  Being consistent with our error checking also
> means that we can spot places where it might practically be a problem
> more easily, it's even easier if the error checking is there first time
> but it's still worth it to go back later.

... yes, but only when it's done correctly.

This is again a typical problem by such a trivial fix patch: the code
looks as if it were trivial and correct, buried in a patch series that
easily leads to the oversight by the maintainer's review.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:31       ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:31 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	garsilva, Christophe JAILLET, arvind.yadav.cs, Alexandre Belloni,
	andriy.shevchenko, bhumirks

On Thu, 31 Aug 2017 12:19:03 +0200,
Mark Brown wrote:
> 
> On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:
> 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> 
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> It may currently be the case that the SoCs you're looking at happen to
> make this clock essential but that doesn't mean that it's not going to
> be different in some future SoC, nor that we can't have a software bug
> that this will detect.  Being consistent with our error checking also
> means that we can spot places where it might practically be a problem
> more easily, it's even easier if the error checking is there first time
> but it's still worth it to go back later.

... yes, but only when it's done correctly.

This is again a typical problem by such a trivial fix patch: the code
looks as if it were trivial and correct, buried in a patch series that
easily leads to the oversight by the maintainer's review.


thanks,

Takashi

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:31       ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:31 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	garsilva, Christophe JAILLET, arvind.yadav.cs, Alexandre Belloni,
	andriy.shevchenko, bhumirks

On Thu, 31 Aug 2017 12:19:03 +0200,
Mark Brown wrote:
> 
> On Thu, Aug 31, 2017 at 10:10:21AM +0200, Alexandre Belloni wrote:
> 
> > And here is the fallout of the stupid, brainless "fixing" of issues
> > reported by static analysis tools.
> 
> > This clk_prepare_enable will never fail. If it was going to fail, the
> > platform would never boot to a point were it is able to execute that
> > code. It is really annoying to have so much churn for absolutely 0
> > benefit.
> 
> It may currently be the case that the SoCs you're looking at happen to
> make this clock essential but that doesn't mean that it's not going to
> be different in some future SoC, nor that we can't have a software bug
> that this will detect.  Being consistent with our error checking also
> means that we can spot places where it might practically be a problem
> more easily, it's even easier if the error checking is there first time
> but it's still worth it to go back later.

... yes, but only when it's done correctly.

This is again a typical problem by such a trivial fix patch: the code
looks as if it were trivial and correct, buried in a patch series that
easily leads to the oversight by the maintainer's review.


thanks,

Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:23           ` Takashi Iwai
  (?)
@ 2017-08-31 10:37             ` Mark Brown
  -1 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:37 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Alexandre Belloni, Julia Lawall, alsa-devel, garsilva,
	arvind.yadav.cs, bhumirks, andriy.shevchenko, nicolas.ferre,
	perex, kernel-janitors, linux-kernel, Christophe JAILLET

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

On Thu, Aug 31, 2017 at 12:23:14PM +0200, Takashi Iwai wrote:

> Ah, wait, now I see your point.  It was introduced by the very recent
> patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
> while it isn't).  That patch looks indeed fishy.  The change in
> atmel_ac97c_resume() is also bad.

The resume check looks fine?  The function appears to do nothing other
than the clk_prepare_enable().

> So, I'd prefer reverting the wrong commit instead, and leave some
> comment about the uselessness of clk_prepare_enable() return value
> check.

I'd rather keep the error checking there, it means that people don't
need to open the code and verify it when they go scanning for potential
problems.

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

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:37             ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:37 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, Julia Lawall, Alexandre Belloni,
	Christophe JAILLET, arvind.yadav.cs, andriy.shevchenko, bhumirks

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

On Thu, Aug 31, 2017 at 12:23:14PM +0200, Takashi Iwai wrote:

> Ah, wait, now I see your point.  It was introduced by the very recent
> patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
> while it isn't).  That patch looks indeed fishy.  The change in
> atmel_ac97c_resume() is also bad.

The resume check looks fine?  The function appears to do nothing other
than the clk_prepare_enable().

> So, I'd prefer reverting the wrong commit instead, and leave some
> comment about the uselessness of clk_prepare_enable() return value
> check.

I'd rather keep the error checking there, it means that people don't
need to open the code and verify it when they go scanning for potential
problems.

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

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:37             ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:37 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, linux-kernel, garsilva, kernel-janitors,
	nicolas.ferre, Julia Lawall, Alexandre Belloni,
	Christophe JAILLET, arvind.yadav.cs, andriy.shevchenko, bhumirks


[-- Attachment #1.1: Type: text/plain, Size: 712 bytes --]

On Thu, Aug 31, 2017 at 12:23:14PM +0200, Takashi Iwai wrote:

> Ah, wait, now I see your point.  It was introduced by the very recent
> patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
> while it isn't).  That patch looks indeed fishy.  The change in
> atmel_ac97c_resume() is also bad.

The resume check looks fine?  The function appears to do nothing other
than the clk_prepare_enable().

> So, I'd prefer reverting the wrong commit instead, and leave some
> comment about the uselessness of clk_prepare_enable() return value
> check.

I'd rather keep the error checking there, it means that people don't
need to open the code and verify it when they go scanning for potential
problems.

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:31       ` [alsa-devel] " Takashi Iwai
  (?)
@ 2017-08-31 10:38         ` Mark Brown
  -1 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:38 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Alexandre Belloni, alsa-devel, garsilva, arvind.yadav.cs,
	bhumirks, andriy.shevchenko, nicolas.ferre, perex,
	kernel-janitors, linux-kernel, Christophe JAILLET

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

On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:

> This is again a typical problem by such a trivial fix patch: the code
> looks as if it were trivial and correct, buried in a patch series that
> easily leads to the oversight by the maintainer's review.

Right, plus the amount of context that diff shows you.

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

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:38         ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:38 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	garsilva, Christophe JAILLET, arvind.yadav.cs, Alexandre Belloni,
	andriy.shevchenko, bhumirks

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

On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:

> This is again a typical problem by such a trivial fix patch: the code
> looks as if it were trivial and correct, buried in a patch series that
> easily leads to the oversight by the maintainer's review.

Right, plus the amount of context that diff shows you.

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

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:38         ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 10:38 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	garsilva, Christophe JAILLET, arvind.yadav.cs, Alexandre Belloni,
	andriy.shevchenko, bhumirks


[-- Attachment #1.1: Type: text/plain, Size: 324 bytes --]

On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:

> This is again a typical problem by such a trivial fix patch: the code
> looks as if it were trivial and correct, buried in a patch series that
> easily leads to the oversight by the maintainer's review.

Right, plus the amount of context that diff shows you.

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:37             ` [alsa-devel] " Mark Brown
@ 2017-08-31 10:49               ` Takashi Iwai
  -1 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:49 UTC (permalink / raw)
  To: Mark Brown
  Cc: Alexandre Belloni, Julia Lawall, alsa-devel, garsilva,
	arvind.yadav.cs, bhumirks, andriy.shevchenko, nicolas.ferre,
	perex, kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:37:16 +0200,
Mark Brown wrote:
> 
> On Thu, Aug 31, 2017 at 12:23:14PM +0200, Takashi Iwai wrote:
> 
> > Ah, wait, now I see your point.  It was introduced by the very recent
> > patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
> > while it isn't).  That patch looks indeed fishy.  The change in
> > atmel_ac97c_resume() is also bad.
> 
> The resume check looks fine?  The function appears to do nothing other
> than the clk_prepare_enable().

Well, the patch behaves correctly but the code is ugly:
	
        int ret = clk_prepare_enable(chip->pclk);

        return ret;


> > So, I'd prefer reverting the wrong commit instead, and leave some
> > comment about the uselessness of clk_prepare_enable() return value
> > check.
> 
> I'd rather keep the error checking there, it means that people don't
> need to open the code and verify it when they go scanning for potential
> problems.

OK.


Takashi

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

* Re: [alsa-devel] [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 10:49               ` Takashi Iwai
  0 siblings, 0 replies; 55+ messages in thread
From: Takashi Iwai @ 2017-08-31 10:49 UTC (permalink / raw)
  To: Mark Brown
  Cc: Alexandre Belloni, Julia Lawall, alsa-devel, garsilva,
	arvind.yadav.cs, bhumirks, andriy.shevchenko, nicolas.ferre,
	perex, kernel-janitors, linux-kernel, Christophe JAILLET

On Thu, 31 Aug 2017 12:37:16 +0200,
Mark Brown wrote:
> 
> On Thu, Aug 31, 2017 at 12:23:14PM +0200, Takashi Iwai wrote:
> 
> > Ah, wait, now I see your point.  It was introduced by the very recent
> > patch through Mark's asoc tree (since it was wrongly labeled as "ASoC"
> > while it isn't).  That patch looks indeed fishy.  The change in
> > atmel_ac97c_resume() is also bad.
> 
> The resume check looks fine?  The function appears to do nothing other
> than the clk_prepare_enable().

Well, the patch behaves correctly but the code is ugly:
	
        int ret = clk_prepare_enable(chip->pclk);

        return ret;


> > So, I'd prefer reverting the wrong commit instead, and leave some
> > comment about the uselessness of clk_prepare_enable() return value
> > check.
> 
> I'd rather keep the error checking there, it means that people don't
> need to open the code and verify it when they go scanning for potential
> problems.

OK.


Takashi

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

* Applied "ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'" to the asoc tree
  2017-08-31  4:40 ` Christophe JAILLET
  (?)
@ 2017-08-31 11:55   ` Mark Brown
  -1 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 11:55 UTC (permalink / raw)
  To: Christophe Jaillet
  Cc: Christophe JAILLET, Alexandre Belloni, Mark Brown, perex, tiwai,
	arvind.yadav.cs, nicolas.ferre, broonie, garsilva,
	andriy.shevchenko, bhumirks, Christophe JAILLET, alsa-devel,
	kernel-janitors, linux-kernel, alsa-devel

The patch

   ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 0515760fa1159ffa863c7b2b73466aaff7d11a80 Mon Sep 17 00:00:00 2001
From: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Date: Thu, 31 Aug 2017 06:40:42 +0200
Subject: [PATCH] ALSA: ac97c: Fix an error handling path in
 'atmel_ac97c_probe()'

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 52b0522fda20..d78405329ceb 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.14.1

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

* Applied "ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'" to the asoc tree
@ 2017-08-31 11:55   ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 11:55 UTC (permalink / raw)
  Cc: Christophe JAILLET, Alexandre Belloni, Mark Brown, perex, tiwai,
	arvind.yadav.cs

The patch

   ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 0515760fa1159ffa863c7b2b73466aaff7d11a80 Mon Sep 17 00:00:00 2001
From: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Date: Thu, 31 Aug 2017 06:40:42 +0200
Subject: [PATCH] ALSA: ac97c: Fix an error handling path in
 'atmel_ac97c_probe()'

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 52b0522fda20..d78405329ceb 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.14.1


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

* Applied "ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'" to the asoc tree
@ 2017-08-31 11:55   ` Mark Brown
  0 siblings, 0 replies; 55+ messages in thread
From: Mark Brown @ 2017-08-31 11:55 UTC (permalink / raw)
  Cc: Christophe JAILLET, Alexandre Belloni, Mark Brown, perex, tiwai,
	arvind.yadav.cs, nicolas.ferre

The patch

   ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 0515760fa1159ffa863c7b2b73466aaff7d11a80 Mon Sep 17 00:00:00 2001
From: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Date: Thu, 31 Aug 2017 06:40:42 +0200
Subject: [PATCH] ALSA: ac97c: Fix an error handling path in
 'atmel_ac97c_probe()'

If 'clk_prepare_enable()' fails, we must release some resources before
returning. Add a new label in the existing error handling path and 'goto'
there.

Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/atmel/ac97c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 52b0522fda20..d78405329ceb 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	}
 	retval = clk_prepare_enable(pclk);
 	if (retval)
-		return retval;
+		goto err_prepare_enable;
 
 	retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
 			      SNDRV_DEFAULT_STR1, THIS_MODULE,
@@ -881,6 +881,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
 	snd_card_free(card);
 err_snd_card_new:
 	clk_disable_unprepare(pclk);
+err_prepare_enable:
 	clk_put(pclk);
 	return retval;
 }
-- 
2.14.1


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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 10:38         ` [alsa-devel] " Mark Brown
  (?)
@ 2017-08-31 19:08           ` Christophe JAILLET
  -1 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31 19:08 UTC (permalink / raw)
  To: Mark Brown, Takashi Iwai
  Cc: alsa-devel, linux-kernel, kernel-janitors, nicolas.ferre,
	garsilva, arvind.yadav.cs, Alexandre Belloni, andriy.shevchenko,
	bhumirks

Le 31/08/2017 à 12:38, Mark Brown a écrit :
> On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
>
>> This is again a typical problem by such a trivial fix patch: the code
>> looks as if it were trivial and correct, buried in a patch series that
>> easily leads to the oversight by the maintainer's review.
> Right, plus the amount of context that diff shows you.
>
Hi,

My proposed patch was initially triggered using coccinelle, as you must 
have guessed.

In fact, I was surprised by the initial commit.
I don't have any strong opinion if testing the return value of 
'clk_prepare_enable()' is relevant or not, but I was surprised that the 
error handling path had not been updated at the same time.

So, before posting my patch, I have searched a bit in git history and it 
gave:

git shortlog --author="Arvind Yadav" | grep clk_prepare
       ata: sata_rcar: Handle return value of clk_prepare_enable
       hwrng: omap3-rom - Handle return value of clk_prepare_enable
       crypto: img-hash - Handle return value of clk_prepare_enable
       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
       gpio: davinci: Handle return value of clk_prepare_enable
       cpufreq: kirkwood-cpufreq:- Handle return value of 
clk_prepare_enable()
       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
       Input: s3c2410_ts - handle return value of clk_prepare_enable
       iio: adc: xilinx: Handle return value of clk_prepare_enable
       iio:adc:lpc32xx Handle return value of clk_prepare_enable
       memory: ti-aemif: Handle return value of clk_prepare_enable
       spi: davinci: Handle return value of clk_prepare_enable
       [media] tc358743: Handle return value of clk_prepare_enable
       mtd: nand: orion: Handle return value of clk_prepare_enable
       iio: Aspeed ADC - Handle return value of clk_prepare_enable
       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       video: fbdev: pxafb: Handle return value of clk_prepare_enable
       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
       usb: dwc3: exynos: Handle return value of clk_prepare_enable
       i2c: at91: Handle return value of clk_prepare_enable
       i2c: emev2: Handle return value of clk_prepare_enable
       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
       thermal: imx: Handle return value of clk_prepare_enable
       thermal: hisilicon: Handle return value of clk_prepare_enable
       PCI: rockchip: Check for clk_prepare_enable() errors during resume
       watchdog: meson: Handle return value of clk_prepare_enable
       watchdog: davinci: Handle return value of clk_prepare_enable
       mfd: tc6393xb: Handle return value of clk_prepare_enable
       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
       ASoC: mxs-saif: Handle return value of 
clk_prepare_enable/clk_prepare.
       ASoC: jz4740: Handle return value of clk_prepare_enable.
       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
       gpio: mb86s7x: Handle return value of clk_prepare_enable.
       memory: mtk-smi: Handle return value of clk_prepare_enable
       mmc: sdhci-st: Handle return value of clk_prepare_enable
       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
       mmc: mxcmmc: Handle return value of clk_prepare_enable
       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
       mtd: nand: denali: Handle return value of clk_prepare_enable.
       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.

Some of these are after a devm_clk_get(), which does not require a 
modification in the error handling path (at least according to the one 
I've looked at)

Some don't have any [devm_]clk_get() in the same function, and were not 
investigated further.

But several also had the same construction as the one reported in this 
thread, and needed, IMHO, an update of the error handling path to call 
through clk_put().


It was "too" surprising to me to have "all" these "obviously" incomplete 
patches merged.
I thought that I had missed something obvious and decided to propose one 
fix to see the reaction (and didn't expected all your replies!)

So now, I think we should go through the commits above to either revert 
the commit and remove the test (and document why it is not needed) or 
fix the error handling path accordingly, even if one could know that it 
cant' happen.

CJ

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 19:08           ` Christophe JAILLET
  0 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31 19:08 UTC (permalink / raw)
  To: Mark Brown, Takashi Iwai
  Cc: alsa-devel, Alexandre Belloni, kernel-janitors, linux-kernel,
	nicolas.ferre, garsilva, arvind.yadav.cs, andriy.shevchenko,
	bhumirks

Le 31/08/2017 à 12:38, Mark Brown a écrit :
> On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
>
>> This is again a typical problem by such a trivial fix patch: the code
>> looks as if it were trivial and correct, buried in a patch series that
>> easily leads to the oversight by the maintainer's review.
> Right, plus the amount of context that diff shows you.
>
Hi,

My proposed patch was initially triggered using coccinelle, as you must 
have guessed.

In fact, I was surprised by the initial commit.
I don't have any strong opinion if testing the return value of 
'clk_prepare_enable()' is relevant or not, but I was surprised that the 
error handling path had not been updated at the same time.

So, before posting my patch, I have searched a bit in git history and it 
gave:

git shortlog --author="Arvind Yadav" | grep clk_prepare
       ata: sata_rcar: Handle return value of clk_prepare_enable
       hwrng: omap3-rom - Handle return value of clk_prepare_enable
       crypto: img-hash - Handle return value of clk_prepare_enable
       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
       gpio: davinci: Handle return value of clk_prepare_enable
       cpufreq: kirkwood-cpufreq:- Handle return value of 
clk_prepare_enable()
       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
       Input: s3c2410_ts - handle return value of clk_prepare_enable
       iio: adc: xilinx: Handle return value of clk_prepare_enable
       iio:adc:lpc32xx Handle return value of clk_prepare_enable
       memory: ti-aemif: Handle return value of clk_prepare_enable
       spi: davinci: Handle return value of clk_prepare_enable
       [media] tc358743: Handle return value of clk_prepare_enable
       mtd: nand: orion: Handle return value of clk_prepare_enable
       iio: Aspeed ADC - Handle return value of clk_prepare_enable
       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       video: fbdev: pxafb: Handle return value of clk_prepare_enable
       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
       usb: dwc3: exynos: Handle return value of clk_prepare_enable
       i2c: at91: Handle return value of clk_prepare_enable
       i2c: emev2: Handle return value of clk_prepare_enable
       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
       thermal: imx: Handle return value of clk_prepare_enable
       thermal: hisilicon: Handle return value of clk_prepare_enable
       PCI: rockchip: Check for clk_prepare_enable() errors during resume
       watchdog: meson: Handle return value of clk_prepare_enable
       watchdog: davinci: Handle return value of clk_prepare_enable
       mfd: tc6393xb: Handle return value of clk_prepare_enable
       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
       ASoC: mxs-saif: Handle return value of 
clk_prepare_enable/clk_prepare.
       ASoC: jz4740: Handle return value of clk_prepare_enable.
       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
       gpio: mb86s7x: Handle return value of clk_prepare_enable.
       memory: mtk-smi: Handle return value of clk_prepare_enable
       mmc: sdhci-st: Handle return value of clk_prepare_enable
       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
       mmc: mxcmmc: Handle return value of clk_prepare_enable
       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
       mtd: nand: denali: Handle return value of clk_prepare_enable.
       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.

Some of these are after a devm_clk_get(), which does not require a 
modification in the error handling path (at least according to the one 
I've looked at)

Some don't have any [devm_]clk_get() in the same function, and were not 
investigated further.

But several also had the same construction as the one reported in this 
thread, and needed, IMHO, an update of the error handling path to call 
through clk_put().


It was "too" surprising to me to have "all" these "obviously" incomplete 
patches merged.
I thought that I had missed something obvious and decided to propose one 
fix to see the reaction (and didn't expected all your replies!)

So now, I think we should go through the commits above to either revert 
the commit and remove the test (and document why it is not needed) or 
fix the error handling path accordingly, even if one could know that it 
cant' happen.

CJ

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 19:08           ` Christophe JAILLET
  0 siblings, 0 replies; 55+ messages in thread
From: Christophe JAILLET @ 2017-08-31 19:08 UTC (permalink / raw)
  To: Mark Brown, Takashi Iwai
  Cc: alsa-devel, Alexandre Belloni, kernel-janitors, linux-kernel,
	nicolas.ferre, garsilva, arvind.yadav.cs, andriy.shevchenko,
	bhumirks

Le 31/08/2017 à 12:38, Mark Brown a écrit :
> On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
>
>> This is again a typical problem by such a trivial fix patch: the code
>> looks as if it were trivial and correct, buried in a patch series that
>> easily leads to the oversight by the maintainer's review.
> Right, plus the amount of context that diff shows you.
>
Hi,

My proposed patch was initially triggered using coccinelle, as you must 
have guessed.

In fact, I was surprised by the initial commit.
I don't have any strong opinion if testing the return value of 
'clk_prepare_enable()' is relevant or not, but I was surprised that the 
error handling path had not been updated at the same time.

So, before posting my patch, I have searched a bit in git history and it 
gave:

git shortlog --author="Arvind Yadav" | grep clk_prepare
       ata: sata_rcar: Handle return value of clk_prepare_enable
       hwrng: omap3-rom - Handle return value of clk_prepare_enable
       crypto: img-hash - Handle return value of clk_prepare_enable
       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
       gpio: davinci: Handle return value of clk_prepare_enable
       cpufreq: kirkwood-cpufreq:- Handle return value of 
clk_prepare_enable()
       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
       Input: s3c2410_ts - handle return value of clk_prepare_enable
       iio: adc: xilinx: Handle return value of clk_prepare_enable
       iio:adc:lpc32xx Handle return value of clk_prepare_enable
       memory: ti-aemif: Handle return value of clk_prepare_enable
       spi: davinci: Handle return value of clk_prepare_enable
       [media] tc358743: Handle return value of clk_prepare_enable
       mtd: nand: orion: Handle return value of clk_prepare_enable
       iio: Aspeed ADC - Handle return value of clk_prepare_enable
       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       usb: mtu3: Handle return value of clk_prepare_enable
       video: fbdev: pxafb: Handle return value of clk_prepare_enable
       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
       usb: dwc3: exynos: Handle return value of clk_prepare_enable
       i2c: at91: Handle return value of clk_prepare_enable
       i2c: emev2: Handle return value of clk_prepare_enable
       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
       thermal: imx: Handle return value of clk_prepare_enable
       thermal: hisilicon: Handle return value of clk_prepare_enable
       PCI: rockchip: Check for clk_prepare_enable() errors during resume
       watchdog: meson: Handle return value of clk_prepare_enable
       watchdog: davinci: Handle return value of clk_prepare_enable
       mfd: tc6393xb: Handle return value of clk_prepare_enable
       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
       ASoC: mxs-saif: Handle return value of 
clk_prepare_enable/clk_prepare.
       ASoC: jz4740: Handle return value of clk_prepare_enable.
       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
       gpio: mb86s7x: Handle return value of clk_prepare_enable.
       memory: mtk-smi: Handle return value of clk_prepare_enable
       mmc: sdhci-st: Handle return value of clk_prepare_enable
       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
       mmc: mxcmmc: Handle return value of clk_prepare_enable
       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
       mtd: nand: denali: Handle return value of clk_prepare_enable.
       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.

Some of these are after a devm_clk_get(), which does not require a 
modification in the error handling path (at least according to the one 
I've looked at)

Some don't have any [devm_]clk_get() in the same function, and were not 
investigated further.

But several also had the same construction as the one reported in this 
thread, and needed, IMHO, an update of the error handling path to call 
through clk_put().


It was "too" surprising to me to have "all" these "obviously" incomplete 
patches merged.
I thought that I had missed something obvious and decided to propose one 
fix to see the reaction (and didn't expected all your replies!)

So now, I think we should go through the commits above to either revert 
the commit and remove the test (and document why it is not needed) or 
fix the error handling path accordingly, even if one could know that it 
cant' happen.

CJ

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 19:08           ` Christophe JAILLET
@ 2017-08-31 20:50             ` Alexandre Belloni
  -1 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31 20:50 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mark Brown, Takashi Iwai, alsa-devel, linux-kernel,
	kernel-janitors, nicolas.ferre, garsilva, arvind.yadav.cs,
	andriy.shevchenko, bhumirks

Hi,

On 31/08/2017 at 21:08:10 +0200, Christophe JAILLET wrote:
> Le 31/08/2017 à 12:38, Mark Brown a écrit :
> > On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
> > 
> > > This is again a typical problem by such a trivial fix patch: the code
> > > looks as if it were trivial and correct, buried in a patch series that
> > > easily leads to the oversight by the maintainer's review.
> > Right, plus the amount of context that diff shows you.
> > 
> Hi,
> 
> My proposed patch was initially triggered using coccinelle, as you must have
> guessed.
> 
> In fact, I was surprised by the initial commit.
> I don't have any strong opinion if testing the return value of
> 'clk_prepare_enable()' is relevant or not, but I was surprised that the
> error handling path had not been updated at the same time.
> 
> So, before posting my patch, I have searched a bit in git history and it
> gave:
> 
> git shortlog --author="Arvind Yadav" | grep clk_prepare
>       ata: sata_rcar: Handle return value of clk_prepare_enable
>       hwrng: omap3-rom - Handle return value of clk_prepare_enable
>       crypto: img-hash - Handle return value of clk_prepare_enable
>       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
>       gpio: davinci: Handle return value of clk_prepare_enable
>       cpufreq: kirkwood-cpufreq:- Handle return value of
> clk_prepare_enable()
>       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
>       Input: s3c2410_ts - handle return value of clk_prepare_enable
>       iio: adc: xilinx: Handle return value of clk_prepare_enable
>       iio:adc:lpc32xx Handle return value of clk_prepare_enable
>       memory: ti-aemif: Handle return value of clk_prepare_enable
>       spi: davinci: Handle return value of clk_prepare_enable
>       [media] tc358743: Handle return value of clk_prepare_enable
>       mtd: nand: orion: Handle return value of clk_prepare_enable
>       iio: Aspeed ADC - Handle return value of clk_prepare_enable
>       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
>       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
>       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
>       usb: mtu3: Handle return value of clk_prepare_enable
>       usb: mtu3: Handle return value of clk_prepare_enable
>       video: fbdev: pxafb: Handle return value of clk_prepare_enable
>       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
>       usb: dwc3: exynos: Handle return value of clk_prepare_enable
>       i2c: at91: Handle return value of clk_prepare_enable
>       i2c: emev2: Handle return value of clk_prepare_enable
>       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
>       thermal: imx: Handle return value of clk_prepare_enable
>       thermal: hisilicon: Handle return value of clk_prepare_enable
>       PCI: rockchip: Check for clk_prepare_enable() errors during resume
>       watchdog: meson: Handle return value of clk_prepare_enable
>       watchdog: davinci: Handle return value of clk_prepare_enable
>       mfd: tc6393xb: Handle return value of clk_prepare_enable
>       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
>       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
>       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
>       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
>       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
>       ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare.
>       ASoC: jz4740: Handle return value of clk_prepare_enable.
>       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
>       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
>       gpio: mb86s7x: Handle return value of clk_prepare_enable.
>       memory: mtk-smi: Handle return value of clk_prepare_enable
>       mmc: sdhci-st: Handle return value of clk_prepare_enable
>       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
>       mmc: mxcmmc: Handle return value of clk_prepare_enable
>       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
>       mtd: nand: denali: Handle return value of clk_prepare_enable.
>       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
>       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
>       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
>       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.
> 
> Some of these are after a devm_clk_get(), which does not require a
> modification in the error handling path (at least according to the one I've
> looked at)
> 
> Some don't have any [devm_]clk_get() in the same function, and were not
> investigated further.
> 
> But several also had the same construction as the one reported in this
> thread, and needed, IMHO, an update of the error handling path to call
> through clk_put().
> 
> 
> It was "too" surprising to me to have "all" these "obviously" incomplete
> patches merged.
> I thought that I had missed something obvious and decided to propose one fix
> to see the reaction (and didn't expected all your replies!)
> 

You didn't miss anything, that's exactly what I am complaining about
some of the patches were OK, some aren't and all the real work is left
to the maintainer.

> So now, I think we should go through the commits above to either revert the
> commit and remove the test (and document why it is not needed) or fix the
> error handling path accordingly, even if one could know that it cant'
> happen.

I think you should go ahead and fix those now...

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 20:50             ` Alexandre Belloni
  0 siblings, 0 replies; 55+ messages in thread
From: Alexandre Belloni @ 2017-08-31 20:50 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mark Brown, Takashi Iwai, alsa-devel, linux-kernel,
	kernel-janitors, nicolas.ferre, garsilva, arvind.yadav.cs,
	andriy.shevchenko, bhumirks

Hi,

On 31/08/2017 at 21:08:10 +0200, Christophe JAILLET wrote:
> Le 31/08/2017 à 12:38, Mark Brown a écrit :
> > On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
> > 
> > > This is again a typical problem by such a trivial fix patch: the code
> > > looks as if it were trivial and correct, buried in a patch series that
> > > easily leads to the oversight by the maintainer's review.
> > Right, plus the amount of context that diff shows you.
> > 
> Hi,
> 
> My proposed patch was initially triggered using coccinelle, as you must have
> guessed.
> 
> In fact, I was surprised by the initial commit.
> I don't have any strong opinion if testing the return value of
> 'clk_prepare_enable()' is relevant or not, but I was surprised that the
> error handling path had not been updated at the same time.
> 
> So, before posting my patch, I have searched a bit in git history and it
> gave:
> 
> git shortlog --author="Arvind Yadav" | grep clk_prepare
>       ata: sata_rcar: Handle return value of clk_prepare_enable
>       hwrng: omap3-rom - Handle return value of clk_prepare_enable
>       crypto: img-hash - Handle return value of clk_prepare_enable
>       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
>       gpio: davinci: Handle return value of clk_prepare_enable
>       cpufreq: kirkwood-cpufreq:- Handle return value of
> clk_prepare_enable()
>       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
>       Input: s3c2410_ts - handle return value of clk_prepare_enable
>       iio: adc: xilinx: Handle return value of clk_prepare_enable
>       iio:adc:lpc32xx Handle return value of clk_prepare_enable
>       memory: ti-aemif: Handle return value of clk_prepare_enable
>       spi: davinci: Handle return value of clk_prepare_enable
>       [media] tc358743: Handle return value of clk_prepare_enable
>       mtd: nand: orion: Handle return value of clk_prepare_enable
>       iio: Aspeed ADC - Handle return value of clk_prepare_enable
>       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
>       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
>       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
>       usb: mtu3: Handle return value of clk_prepare_enable
>       usb: mtu3: Handle return value of clk_prepare_enable
>       video: fbdev: pxafb: Handle return value of clk_prepare_enable
>       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
>       usb: dwc3: exynos: Handle return value of clk_prepare_enable
>       i2c: at91: Handle return value of clk_prepare_enable
>       i2c: emev2: Handle return value of clk_prepare_enable
>       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
>       thermal: imx: Handle return value of clk_prepare_enable
>       thermal: hisilicon: Handle return value of clk_prepare_enable
>       PCI: rockchip: Check for clk_prepare_enable() errors during resume
>       watchdog: meson: Handle return value of clk_prepare_enable
>       watchdog: davinci: Handle return value of clk_prepare_enable
>       mfd: tc6393xb: Handle return value of clk_prepare_enable
>       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
>       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
>       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
>       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
>       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
>       ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare.
>       ASoC: jz4740: Handle return value of clk_prepare_enable.
>       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
>       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
>       gpio: mb86s7x: Handle return value of clk_prepare_enable.
>       memory: mtk-smi: Handle return value of clk_prepare_enable
>       mmc: sdhci-st: Handle return value of clk_prepare_enable
>       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
>       mmc: mxcmmc: Handle return value of clk_prepare_enable
>       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
>       mtd: nand: denali: Handle return value of clk_prepare_enable.
>       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
>       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
>       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
>       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.
> 
> Some of these are after a devm_clk_get(), which does not require a
> modification in the error handling path (at least according to the one I've
> looked at)
> 
> Some don't have any [devm_]clk_get() in the same function, and were not
> investigated further.
> 
> But several also had the same construction as the one reported in this
> thread, and needed, IMHO, an update of the error handling path to call
> through clk_put().
> 
> 
> It was "too" surprising to me to have "all" these "obviously" incomplete
> patches merged.
> I thought that I had missed something obvious and decided to propose one fix
> to see the reaction (and didn't expected all your replies!)
> 

You didn't miss anything, that's exactly what I am complaining about
some of the patches were OK, some aren't and all the real work is left
to the maintainer.

> So now, I think we should go through the commits above to either revert the
> commit and remove the test (and document why it is not needed) or fix the
> error handling path accordingly, even if one could know that it cant'
> happen.

I think you should go ahead and fix those now...

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
  2017-08-31 20:50             ` Alexandre Belloni
  (?)
@ 2017-08-31 21:07               ` Julia Lawall
  -1 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31 21:07 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Christophe JAILLET, Mark Brown, Takashi Iwai, alsa-devel,
	linux-kernel, kernel-janitors, nicolas.ferre, garsilva,
	arvind.yadav.cs, andriy.shevchenko, bhumirks

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



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> Hi,
>
> On 31/08/2017 at 21:08:10 +0200, Christophe JAILLET wrote:
> > Le 31/08/2017 à 12:38, Mark Brown a écrit :
> > > On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
> > >
> > > > This is again a typical problem by such a trivial fix patch: the code
> > > > looks as if it were trivial and correct, buried in a patch series that
> > > > easily leads to the oversight by the maintainer's review.
> > > Right, plus the amount of context that diff shows you.
> > >
> > Hi,
> >
> > My proposed patch was initially triggered using coccinelle, as you must have
> > guessed.
> >
> > In fact, I was surprised by the initial commit.
> > I don't have any strong opinion if testing the return value of
> > 'clk_prepare_enable()' is relevant or not, but I was surprised that the
> > error handling path had not been updated at the same time.
> >
> > So, before posting my patch, I have searched a bit in git history and it
> > gave:
> >
> > git shortlog --author="Arvind Yadav" | grep clk_prepare
> >       ata: sata_rcar: Handle return value of clk_prepare_enable
> >       hwrng: omap3-rom - Handle return value of clk_prepare_enable
> >       crypto: img-hash - Handle return value of clk_prepare_enable
> >       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
> >       gpio: davinci: Handle return value of clk_prepare_enable
> >       cpufreq: kirkwood-cpufreq:- Handle return value of
> > clk_prepare_enable()
> >       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
> >       Input: s3c2410_ts - handle return value of clk_prepare_enable
> >       iio: adc: xilinx: Handle return value of clk_prepare_enable
> >       iio:adc:lpc32xx Handle return value of clk_prepare_enable
> >       memory: ti-aemif: Handle return value of clk_prepare_enable
> >       spi: davinci: Handle return value of clk_prepare_enable
> >       [media] tc358743: Handle return value of clk_prepare_enable
> >       mtd: nand: orion: Handle return value of clk_prepare_enable
> >       iio: Aspeed ADC - Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
> >       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       video: fbdev: pxafb: Handle return value of clk_prepare_enable
> >       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
> >       usb: dwc3: exynos: Handle return value of clk_prepare_enable
> >       i2c: at91: Handle return value of clk_prepare_enable
> >       i2c: emev2: Handle return value of clk_prepare_enable
> >       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
> >       thermal: imx: Handle return value of clk_prepare_enable
> >       thermal: hisilicon: Handle return value of clk_prepare_enable
> >       PCI: rockchip: Check for clk_prepare_enable() errors during resume
> >       watchdog: meson: Handle return value of clk_prepare_enable
> >       watchdog: davinci: Handle return value of clk_prepare_enable
> >       mfd: tc6393xb: Handle return value of clk_prepare_enable
> >       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
> >       ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare.
> >       ASoC: jz4740: Handle return value of clk_prepare_enable.
> >       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
> >       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
> >       gpio: mb86s7x: Handle return value of clk_prepare_enable.
> >       memory: mtk-smi: Handle return value of clk_prepare_enable
> >       mmc: sdhci-st: Handle return value of clk_prepare_enable
> >       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
> >       mmc: mxcmmc: Handle return value of clk_prepare_enable
> >       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
> >       mtd: nand: denali: Handle return value of clk_prepare_enable.
> >       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
> >       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
> >       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
> >       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.
> >
> > Some of these are after a devm_clk_get(), which does not require a
> > modification in the error handling path (at least according to the one I've
> > looked at)
> >
> > Some don't have any [devm_]clk_get() in the same function, and were not
> > investigated further.
> >
> > But several also had the same construction as the one reported in this
> > thread, and needed, IMHO, an update of the error handling path to call
> > through clk_put().
> >
> >
> > It was "too" surprising to me to have "all" these "obviously" incomplete
> > patches merged.
> > I thought that I had missed something obvious and decided to propose one fix
> > to see the reaction (and didn't expected all your replies!)
> >
>
> You didn't miss anything, that's exactly what I am complaining about
> some of the patches were OK, some aren't and all the real work is left
> to the maintainer.

The commit message is also a bit strange:

clk_prepare_enable() and clk_prepare() can fail here and
we must check its return value.

When someone in the future is tring to understand whether or nor calls to
clk_prepare_enable can fail, it would be misleading to have "can fail" and
"we must check" in the history of a context where failure is not possible.

julia


>
> > So now, I think we should go through the commits above to either revert the
> > commit and remove the test (and document why it is not needed) or fix the
> > error handling path accordingly, even if one could know that it cant'
> > happen.
>
> I think you should go ahead and fix those now...
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 21:07               ` Julia Lawall
  0 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31 21:07 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, Takashi Iwai, kernel-janitors, linux-kernel,
	nicolas.ferre, Mark Brown, Christophe JAILLET, arvind.yadav.cs,
	garsilva, andriy.shevchenko, bhumirks

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



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> Hi,
>
> On 31/08/2017 at 21:08:10 +0200, Christophe JAILLET wrote:
> > Le 31/08/2017 à 12:38, Mark Brown a écrit :
> > > On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
> > >
> > > > This is again a typical problem by such a trivial fix patch: the code
> > > > looks as if it were trivial and correct, buried in a patch series that
> > > > easily leads to the oversight by the maintainer's review.
> > > Right, plus the amount of context that diff shows you.
> > >
> > Hi,
> >
> > My proposed patch was initially triggered using coccinelle, as you must have
> > guessed.
> >
> > In fact, I was surprised by the initial commit.
> > I don't have any strong opinion if testing the return value of
> > 'clk_prepare_enable()' is relevant or not, but I was surprised that the
> > error handling path had not been updated at the same time.
> >
> > So, before posting my patch, I have searched a bit in git history and it
> > gave:
> >
> > git shortlog --author="Arvind Yadav" | grep clk_prepare
> >       ata: sata_rcar: Handle return value of clk_prepare_enable
> >       hwrng: omap3-rom - Handle return value of clk_prepare_enable
> >       crypto: img-hash - Handle return value of clk_prepare_enable
> >       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
> >       gpio: davinci: Handle return value of clk_prepare_enable
> >       cpufreq: kirkwood-cpufreq:- Handle return value of
> > clk_prepare_enable()
> >       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
> >       Input: s3c2410_ts - handle return value of clk_prepare_enable
> >       iio: adc: xilinx: Handle return value of clk_prepare_enable
> >       iio:adc:lpc32xx Handle return value of clk_prepare_enable
> >       memory: ti-aemif: Handle return value of clk_prepare_enable
> >       spi: davinci: Handle return value of clk_prepare_enable
> >       [media] tc358743: Handle return value of clk_prepare_enable
> >       mtd: nand: orion: Handle return value of clk_prepare_enable
> >       iio: Aspeed ADC - Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
> >       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       video: fbdev: pxafb: Handle return value of clk_prepare_enable
> >       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
> >       usb: dwc3: exynos: Handle return value of clk_prepare_enable
> >       i2c: at91: Handle return value of clk_prepare_enable
> >       i2c: emev2: Handle return value of clk_prepare_enable
> >       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
> >       thermal: imx: Handle return value of clk_prepare_enable
> >       thermal: hisilicon: Handle return value of clk_prepare_enable
> >       PCI: rockchip: Check for clk_prepare_enable() errors during resume
> >       watchdog: meson: Handle return value of clk_prepare_enable
> >       watchdog: davinci: Handle return value of clk_prepare_enable
> >       mfd: tc6393xb: Handle return value of clk_prepare_enable
> >       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
> >       ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare.
> >       ASoC: jz4740: Handle return value of clk_prepare_enable.
> >       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
> >       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
> >       gpio: mb86s7x: Handle return value of clk_prepare_enable.
> >       memory: mtk-smi: Handle return value of clk_prepare_enable
> >       mmc: sdhci-st: Handle return value of clk_prepare_enable
> >       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
> >       mmc: mxcmmc: Handle return value of clk_prepare_enable
> >       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
> >       mtd: nand: denali: Handle return value of clk_prepare_enable.
> >       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
> >       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
> >       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
> >       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.
> >
> > Some of these are after a devm_clk_get(), which does not require a
> > modification in the error handling path (at least according to the one I've
> > looked at)
> >
> > Some don't have any [devm_]clk_get() in the same function, and were not
> > investigated further.
> >
> > But several also had the same construction as the one reported in this
> > thread, and needed, IMHO, an update of the error handling path to call
> > through clk_put().
> >
> >
> > It was "too" surprising to me to have "all" these "obviously" incomplete
> > patches merged.
> > I thought that I had missed something obvious and decided to propose one fix
> > to see the reaction (and didn't expected all your replies!)
> >
>
> You didn't miss anything, that's exactly what I am complaining about
> some of the patches were OK, some aren't and all the real work is left
> to the maintainer.

The commit message is also a bit strange:

clk_prepare_enable() and clk_prepare() can fail here and
we must check its return value.

When someone in the future is tring to understand whether or nor calls to
clk_prepare_enable can fail, it would be misleading to have "can fail" and
"we must check" in the history of a context where failure is not possible.

julia


>
> > So now, I think we should go through the commits above to either revert the
> > commit and remove the test (and document why it is not needed) or fix the
> > error handling path accordingly, even if one could know that it cant'
> > happen.
>
> I think you should go ahead and fix those now...
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'
@ 2017-08-31 21:07               ` Julia Lawall
  0 siblings, 0 replies; 55+ messages in thread
From: Julia Lawall @ 2017-08-31 21:07 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, Takashi Iwai, kernel-janitors, linux-kernel,
	nicolas.ferre, Mark Brown, Christophe JAILLET, arvind.yadav.cs,
	garsilva, andriy.shevchenko, bhumirks

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



On Thu, 31 Aug 2017, Alexandre Belloni wrote:

> Hi,
>
> On 31/08/2017 at 21:08:10 +0200, Christophe JAILLET wrote:
> > Le 31/08/2017 à 12:38, Mark Brown a écrit :
> > > On Thu, Aug 31, 2017 at 12:31:33PM +0200, Takashi Iwai wrote:
> > >
> > > > This is again a typical problem by such a trivial fix patch: the code
> > > > looks as if it were trivial and correct, buried in a patch series that
> > > > easily leads to the oversight by the maintainer's review.
> > > Right, plus the amount of context that diff shows you.
> > >
> > Hi,
> >
> > My proposed patch was initially triggered using coccinelle, as you must have
> > guessed.
> >
> > In fact, I was surprised by the initial commit.
> > I don't have any strong opinion if testing the return value of
> > 'clk_prepare_enable()' is relevant or not, but I was surprised that the
> > error handling path had not been updated at the same time.
> >
> > So, before posting my patch, I have searched a bit in git history and it
> > gave:
> >
> > git shortlog --author="Arvind Yadav" | grep clk_prepare
> >       ata: sata_rcar: Handle return value of clk_prepare_enable
> >       hwrng: omap3-rom - Handle return value of clk_prepare_enable
> >       crypto: img-hash - Handle return value of clk_prepare_enable
> >       dmaengine: DW DMAC: Handle return value of clk_prepare_enable
> >       gpio: davinci: Handle return value of clk_prepare_enable
> >       cpufreq: kirkwood-cpufreq:- Handle return value of
> > clk_prepare_enable()
> >       dmaengine: imx-sdma: Handle return value of clk_prepare_enable
> >       Input: s3c2410_ts - handle return value of clk_prepare_enable
> >       iio: adc: xilinx: Handle return value of clk_prepare_enable
> >       iio:adc:lpc32xx Handle return value of clk_prepare_enable
> >       memory: ti-aemif: Handle return value of clk_prepare_enable
> >       spi: davinci: Handle return value of clk_prepare_enable
> >       [media] tc358743: Handle return value of clk_prepare_enable
> >       mtd: nand: orion: Handle return value of clk_prepare_enable
> >       iio: Aspeed ADC - Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-nocp: Handle return value of clk_prepare_enable
> >       PM / devfreq: exynos-ppmu: Handle return value of clk_prepare_enable
> >       usb: host: ehci-exynos: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       usb: mtu3: Handle return value of clk_prepare_enable
> >       video: fbdev: pxafb: Handle return value of clk_prepare_enable
> >       usb: gadget: mv_udc: Handle return value of clk_prepare_enable.
> >       usb: dwc3: exynos: Handle return value of clk_prepare_enable
> >       i2c: at91: Handle return value of clk_prepare_enable
> >       i2c: emev2: Handle return value of clk_prepare_enable
> >       usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
> >       thermal: imx: Handle return value of clk_prepare_enable
> >       thermal: hisilicon: Handle return value of clk_prepare_enable
> >       PCI: rockchip: Check for clk_prepare_enable() errors during resume
> >       watchdog: meson: Handle return value of clk_prepare_enable
> >       watchdog: davinci: Handle return value of clk_prepare_enable
> >       mfd: tc6393xb: Handle return value of clk_prepare_enable
> >       ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: pcm: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: i2s: Handle return value of clk_prepare_enable.
> >       ASoC: samsung: spdif: Handle return value of clk_prepare_enable.
> >       ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare.
> >       ASoC: jz4740: Handle return value of clk_prepare_enable.
> >       ASoC: sun4i-spdif: Handle return value of clk_prepare_enable.
> >       ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.
> >       gpio: mb86s7x: Handle return value of clk_prepare_enable.
> >       memory: mtk-smi: Handle return value of clk_prepare_enable
> >       mmc: sdhci-st: Handle return value of clk_prepare_enable
> >       mmc: wmt-sdmmc: Handle return value of clk_prepare_enable
> >       mmc: mxcmmc: Handle return value of clk_prepare_enable
> >       dmaengine: at_xdmac: Handle return value of clk_prepare_enable.
> >       mtd: nand: denali: Handle return value of clk_prepare_enable.
> >       mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
> >       mtd: nand: lpc32xx_slc: Handle return value of clk_prepare_enable.
> >       mtd: nand: lpc32xx_mlc: Handle return value of clk_prepare_enable.
> >       mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.
> >
> > Some of these are after a devm_clk_get(), which does not require a
> > modification in the error handling path (at least according to the one I've
> > looked at)
> >
> > Some don't have any [devm_]clk_get() in the same function, and were not
> > investigated further.
> >
> > But several also had the same construction as the one reported in this
> > thread, and needed, IMHO, an update of the error handling path to call
> > through clk_put().
> >
> >
> > It was "too" surprising to me to have "all" these "obviously" incomplete
> > patches merged.
> > I thought that I had missed something obvious and decided to propose one fix
> > to see the reaction (and didn't expected all your replies!)
> >
>
> You didn't miss anything, that's exactly what I am complaining about
> some of the patches were OK, some aren't and all the real work is left
> to the maintainer.

The commit message is also a bit strange:

clk_prepare_enable() and clk_prepare() can fail here and
we must check its return value.

When someone in the future is tring to understand whether or nor calls to
clk_prepare_enable can fail, it would be misleading to have "can fail" and
"we must check" in the history of a context where failure is not possible.

julia


>
> > So now, I think we should go through the commits above to either revert the
> > commit and remove the test (and document why it is not needed) or fix the
> > error handling path accordingly, even if one could know that it cant'
> > happen.
>
> I think you should go ahead and fix those now...
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2017-08-31 21:07 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31  4:40 [PATCH] ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()' Christophe JAILLET
2017-08-31  4:40 ` Christophe JAILLET
2017-08-31  4:40 ` Christophe JAILLET
2017-08-31  8:10 ` [alsa-devel] " Alexandre Belloni
2017-08-31  8:10   ` Alexandre Belloni
2017-08-31  8:10   ` [alsa-devel] " Alexandre Belloni
2017-08-31  8:23   ` Julia Lawall
2017-08-31  8:23     ` Julia Lawall
2017-08-31  8:23     ` [alsa-devel] " Julia Lawall
2017-08-31  9:04     ` Andy Shevchenko
2017-08-31  9:04       ` Andy Shevchenko
2017-08-31  9:04       ` [alsa-devel] " Andy Shevchenko
2017-08-31  9:35       ` Alexandre Belloni
2017-08-31  9:35         ` Alexandre Belloni
2017-08-31  9:38         ` Andy Shevchenko
2017-08-31  9:38           ` Andy Shevchenko
2017-08-31  9:57           ` Alexandre Belloni
2017-08-31  9:57             ` Alexandre Belloni
2017-08-31  9:57             ` [alsa-devel] " Alexandre Belloni
2017-08-31  9:56     ` Alexandre Belloni
2017-08-31  9:56       ` Alexandre Belloni
2017-08-31  9:56       ` [alsa-devel] " Alexandre Belloni
2017-08-31 10:13       ` Takashi Iwai
2017-08-31 10:13         ` Takashi Iwai
2017-08-31 10:13         ` [alsa-devel] " Takashi Iwai
2017-08-31 10:19         ` Alexandre Belloni
2017-08-31 10:19           ` Alexandre Belloni
2017-08-31 10:23         ` Takashi Iwai
2017-08-31 10:23           ` Takashi Iwai
2017-08-31 10:23           ` Takashi Iwai
2017-08-31 10:37           ` Mark Brown
2017-08-31 10:37             ` Mark Brown
2017-08-31 10:37             ` [alsa-devel] " Mark Brown
2017-08-31 10:49             ` Takashi Iwai
2017-08-31 10:49               ` Takashi Iwai
2017-08-31 10:19   ` Mark Brown
2017-08-31 10:19     ` Mark Brown
2017-08-31 10:19     ` [alsa-devel] " Mark Brown
2017-08-31 10:31     ` Takashi Iwai
2017-08-31 10:31       ` Takashi Iwai
2017-08-31 10:31       ` [alsa-devel] " Takashi Iwai
2017-08-31 10:38       ` Mark Brown
2017-08-31 10:38         ` Mark Brown
2017-08-31 10:38         ` [alsa-devel] " Mark Brown
2017-08-31 19:08         ` Christophe JAILLET
2017-08-31 19:08           ` Christophe JAILLET
2017-08-31 19:08           ` Christophe JAILLET
2017-08-31 20:50           ` Alexandre Belloni
2017-08-31 20:50             ` Alexandre Belloni
2017-08-31 21:07             ` Julia Lawall
2017-08-31 21:07               ` Julia Lawall
2017-08-31 21:07               ` Julia Lawall
2017-08-31 11:55 ` Applied "ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()'" to the asoc tree Mark Brown
2017-08-31 11:55   ` Mark Brown
2017-08-31 11:55   ` Mark Brown

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.