ASoC: tegra-alt: add check for pointer before access

add check for context pointer before accessing it in suspend.
Also move setting of driver data at the end of probe function.

Change-Id: I5724ee810dd3ca409412aa21d61d35519b1432a3
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/921743
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
This commit is contained in:
Ravindra Lokhande
2015-12-11 11:08:19 +05:30
committed by Sameer Pujar
parent 56e4b6edb2
commit d00fea6da9
12 changed files with 63 additions and 27 deletions

View File

@@ -249,7 +249,9 @@ static int tegra210_admaif_suspend(struct device *dev)
{
struct tegra210_admaif *admaif = dev_get_drvdata(dev);
regcache_mark_dirty(admaif->regmap);
if (admaif)
regcache_mark_dirty(admaif->regmap);
return 0;
}
#endif
@@ -801,8 +803,6 @@ static int tegra210_admaif_probe(struct platform_device *pdev)
goto err;
}
dev_set_drvdata(&pdev->dev, admaif);
admaif->refcnt = 0;
admaif->soc_data = soc_data;
@@ -921,6 +921,8 @@ static int tegra210_admaif_probe(struct platform_device *pdev)
regmap_update_bits(admaif->regmap,
TEGRA210_ADMAIF_GLOBAL_ENABLE, 1, 1);
dev_set_drvdata(&pdev->dev, admaif);
return 0;
err_unregister_codec:

View File

@@ -279,7 +279,9 @@ static int tegra210_adx_suspend(struct device *dev)
{
struct tegra210_adx *adx = dev_get_drvdata(dev);
regcache_mark_dirty(adx->regmap);
if (adx)
regcache_mark_dirty(adx->regmap);
return 0;
}
#endif
@@ -645,7 +647,6 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, adx);
adx->soc_data = soc_data;
@@ -704,6 +705,8 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, adx);
return 0;
err_suspend:

View File

@@ -93,7 +93,9 @@ static int tegra210_afc_suspend(struct device *dev)
{
struct tegra210_afc *afc = dev_get_drvdata(dev);
regcache_mark_dirty(afc->regmap);
if (afc)
regcache_mark_dirty(afc->regmap);
return 0;
}
#endif
@@ -393,7 +395,6 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, afc);
afc->soc_data = soc_data;
@@ -458,6 +459,8 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, afc);
return 0;
err_suspend:

View File

@@ -306,7 +306,9 @@ static int tegra210_amx_suspend(struct device *dev)
{
struct tegra210_amx *amx = dev_get_drvdata(dev);
regcache_mark_dirty(amx->regmap);
if (amx)
regcache_mark_dirty(amx->regmap);
return 0;
}
#endif
@@ -829,7 +831,6 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, amx);
amx->soc_data = soc_data;
memset(amx->map, 0, sizeof(amx->map));
@@ -890,6 +891,8 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, amx);
return 0;
err_suspend:

View File

@@ -112,7 +112,9 @@ static int tegra210_dmic_suspend(struct device *dev)
{
struct tegra210_dmic *dmic = dev_get_drvdata(dev);
regcache_mark_dirty(dmic->regmap);
if (dmic)
regcache_mark_dirty(dmic->regmap);
return 0;
}
#endif
@@ -435,7 +437,6 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, dmic);
dmic->soc_data = soc_data;
@@ -525,6 +526,8 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (of_property_read_string(np, "prod-name", &prod_name) == 0)
tegra_pinctrl_config_prod(&pdev->dev, prod_name);
dev_set_drvdata(&pdev->dev, dmic);
return 0;
err_suspend:

View File

@@ -314,7 +314,9 @@ static int tegra210_i2s_suspend(struct device *dev)
{
struct tegra210_i2s *i2s = dev_get_drvdata(dev);
regcache_mark_dirty(i2s->regmap);
if (i2s)
regcache_mark_dirty(i2s->regmap);
return 0;
}
#endif
@@ -907,7 +909,6 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, i2s);
i2s->soc_data = soc_data;
i2s->tx_mask = i2s->rx_mask = 0xFFFF;
@@ -1081,6 +1082,8 @@ err_dap:
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, i2s);
return 0;
err_suspend:

View File

@@ -88,7 +88,9 @@ static int tegra210_iqc_suspend(struct device *dev)
{
struct tegra210_iqc *iqc = dev_get_drvdata(dev);
regcache_mark_dirty(iqc->regmap);
if (iqc)
regcache_mark_dirty(iqc->regmap);
return 0;
}
#endif
@@ -340,7 +342,6 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, iqc);
iqc->soc_data = soc_data;
@@ -424,6 +425,8 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, iqc);
return 0;
err_suspend:

View File

@@ -108,7 +108,9 @@ static int tegra210_mixer_suspend(struct device *dev)
{
struct tegra210_mixer *mixer = dev_get_drvdata(dev);
regcache_mark_dirty(mixer->regmap);
if (mixer)
regcache_mark_dirty(mixer->regmap);
return 0;
}
#endif
@@ -651,7 +653,6 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, mixer);
mixer->soc_data = soc_data;
mixer->gain_coeff[0] = 0;
@@ -727,6 +728,8 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, mixer);
return 0;
err_suspend:

View File

@@ -91,7 +91,9 @@ static int tegra210_mvc_suspend(struct device *dev)
{
struct tegra210_mvc *mvc = dev_get_drvdata(dev);
regcache_mark_dirty(mvc->regmap);
if (mvc)
regcache_mark_dirty(mvc->regmap);
return 0;
}
#endif
@@ -635,7 +637,6 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, mvc);
mvc->soc_data = soc_data;
@@ -710,6 +711,8 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, mvc);
return 0;
err_suspend:

View File

@@ -84,9 +84,12 @@ static int tegra210_ope_suspend(struct device *dev)
{
struct tegra210_ope *ope = dev_get_drvdata(dev);
regcache_mark_dirty(ope->regmap);
regcache_mark_dirty(ope->peq_regmap);
regcache_mark_dirty(ope->mbdrc_regmap);
if (ope) {
regcache_mark_dirty(ope->regmap);
regcache_mark_dirty(ope->peq_regmap);
regcache_mark_dirty(ope->mbdrc_regmap);
}
return 0;
}
#endif
@@ -353,7 +356,6 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, ope);
ope->soc_data = soc_data;
@@ -388,6 +390,8 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev)
}
regcache_cache_only(ope->regmap, true);
dev_set_drvdata(&pdev->dev, ope);
ret = ope->soc_data->peq_soc_data.init(pdev,
TEGRA210_PEQ_IORESOURCE_MEM);
if (ret < 0) {

View File

@@ -95,7 +95,9 @@ static int tegra210_sfc_suspend(struct device *dev)
{
struct tegra210_sfc *sfc = dev_get_drvdata(dev);
regcache_mark_dirty(sfc->regmap);
if (sfc)
regcache_mark_dirty(sfc->regmap);
return 0;
}
#endif
@@ -864,7 +866,6 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, sfc);
sfc->soc_data = soc_data;
@@ -926,6 +927,8 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
goto err_suspend;
}
dev_set_drvdata(&pdev->dev, sfc);
return 0;
err_suspend:

View File

@@ -107,7 +107,9 @@ static int tegra210_spdif_suspend(struct device *dev)
{
struct tegra210_spdif *spdif = dev_get_drvdata(dev);
regcache_mark_dirty(spdif->regmap);
if (spdif)
regcache_mark_dirty(spdif->regmap);
return 0;
}
#endif
@@ -397,7 +399,6 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, spdif);
spdif->soc_data = soc_data;
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
@@ -473,6 +474,8 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
if (of_property_read_string(np, "prod-name", &prod_name) == 0)
tegra_pinctrl_config_prod(&pdev->dev, prod_name);
dev_set_drvdata(&pdev->dev, spdif);
return 0;
err_suspend: