mirror of https://gitee.com/openkylin/linux.git
ASoC: fsl_ssi: fix kernel panic in probe function
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> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
7d1311b93e
commit
85151461f1
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue