All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function
@ 2014-09-18 18:38 Michael Trimarchi
  2014-09-18 22:40 ` Nicolin Chen
  2014-09-23  1:58 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Trimarchi @ 2014-09-18 18:38 UTC (permalink / raw)
  To: nicoleotsuka; +Cc: broonie, Li.Xiubo, michael, timur, alsa-devel

code can raise a panic when the ssi_private->pdev is null

[...]
	/*
	 * If codec-handle property is missing from SSI node, we assume
	 * that the machine driver uses new binding which does not require
	 * SSI driver to trigger machine driver's probe.
	 */
	if (!of_get_property(np, "codec-handle", NULL))
		goto done;
[...]
	ssi_private->pdev =
		platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
[...]
done:
	if (ssi_private->dai_fmt)
		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);

Proposal was to not use ssi_private->pdev->dev here but adding a new parameter
of *dev pointer to this _set_dai_fmt() -- passing pdev->dev in probe() and
cpu_dai->dev in fsl_ssi_set_dai_fmt().

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
---
 sound/soc/fsl/fsl_ssi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 87eb577..de6ab06 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -748,8 +748,9 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
-		unsigned int fmt)
+static int _fsl_ssi_set_dai_fmt(struct device *dev,
+				struct fsl_ssi_private *ssi_private,
+				unsigned int fmt)
 {
 	struct regmap *regs = ssi_private->regs;
 	u32 strcr = 0, stcr, srcr, scr, mask;
@@ -758,7 +759,7 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
 	ssi_private->dai_fmt = fmt;
 
 	if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) {
-		dev_err(&ssi_private->pdev->dev, "baudclk is missing which is necessary for master mode\n");
+		dev_err(dev, "baudclk is missing which is necessary for master mode\n");
 		return -EINVAL;
 	}
 
@@ -913,7 +914,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 {
 	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
 
-	return _fsl_ssi_set_dai_fmt(ssi_private, fmt);
+	return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi_private, fmt);
 }
 
 /**
@@ -1387,7 +1388,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
 done:
 	if (ssi_private->dai_fmt)
-		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
+		_fsl_ssi_set_dai_fmt(&pdev->dev, ssi_private,
+				     ssi_private->dai_fmt);
 
 	return 0;
 
-- 
1.8.1.2

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

* Re: [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function
  2014-09-18 18:38 [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function Michael Trimarchi
@ 2014-09-18 22:40 ` Nicolin Chen
  2014-09-23  1:58 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolin Chen @ 2014-09-18 22:40 UTC (permalink / raw)
  To: Michael Trimarchi; +Cc: broonie, Li.Xiubo, timur, alsa-devel

On Thu, Sep 18, 2014 at 08:38:09PM +0200, Michael Trimarchi wrote:
> code can raise a panic when the ssi_private->pdev is null
> 
> [...]
> 	/*
> 	 * If codec-handle property is missing from SSI node, we assume
> 	 * that the machine driver uses new binding which does not require
> 	 * SSI driver to trigger machine driver's probe.
> 	 */
> 	if (!of_get_property(np, "codec-handle", NULL))
> 		goto done;
> [...]
> 	ssi_private->pdev =
> 		platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
> [...]
> done:
> 	if (ssi_private->dai_fmt)
> 		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
> 
> Proposal was to not use ssi_private->pdev->dev here but adding a new parameter
> of *dev pointer to this _set_dai_fmt() -- passing pdev->dev in probe() and
> cpu_dai->dev in fsl_ssi_set_dai_fmt().
> 
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
> Cc: Nicolin Chen <nicoleotsuka@gmail.com>

Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

Thank you

> ---
>  sound/soc/fsl/fsl_ssi.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
> index 87eb577..de6ab06 100644
> --- a/sound/soc/fsl/fsl_ssi.c
> +++ b/sound/soc/fsl/fsl_ssi.c
> @@ -748,8 +748,9 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
>  	return 0;
>  }
>  
> -static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
> -		unsigned int fmt)
> +static int _fsl_ssi_set_dai_fmt(struct device *dev,
> +				struct fsl_ssi_private *ssi_private,
> +				unsigned int fmt)
>  {
>  	struct regmap *regs = ssi_private->regs;
>  	u32 strcr = 0, stcr, srcr, scr, mask;
> @@ -758,7 +759,7 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
>  	ssi_private->dai_fmt = fmt;
>  
>  	if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) {
> -		dev_err(&ssi_private->pdev->dev, "baudclk is missing which is necessary for master mode\n");
> +		dev_err(dev, "baudclk is missing which is necessary for master mode\n");
>  		return -EINVAL;
>  	}
>  
> @@ -913,7 +914,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
>  {
>  	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
>  
> -	return _fsl_ssi_set_dai_fmt(ssi_private, fmt);
> +	return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi_private, fmt);
>  }
>  
>  /**
> @@ -1387,7 +1388,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
>  
>  done:
>  	if (ssi_private->dai_fmt)
> -		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
> +		_fsl_ssi_set_dai_fmt(&pdev->dev, ssi_private,
> +				     ssi_private->dai_fmt);
>  
>  	return 0;
>  
> -- 
> 1.8.1.2
> 

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

* Re: [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function
  2014-09-18 18:38 [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function Michael Trimarchi
  2014-09-18 22:40 ` Nicolin Chen
@ 2014-09-23  1:58 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2014-09-23  1:58 UTC (permalink / raw)
  To: Michael Trimarchi; +Cc: nicoleotsuka, alsa-devel, Li.Xiubo, timur


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

On Thu, Sep 18, 2014 at 08:38:09PM +0200, Michael Trimarchi wrote:
> code can raise a panic when the ssi_private->pdev is null

Applied, thanks.  It's not clear why this might ever be NULL though...

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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



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

end of thread, other threads:[~2014-09-23  1:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 18:38 [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function Michael Trimarchi
2014-09-18 22:40 ` Nicolin Chen
2014-09-23  1:58 ` 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.