ASoC: Intel: Balance ACPI device refcount
Subsystems (3)
v2 cover ASoC: Intel: Balance ACPI device refcount
While looking for the open coded put_device(&adev->dev) cases, where adev stands for ACPI device, I noticed that in a few ASoC Intel driver, among others, the refcount is not balanced properly in some cases.
This series fixes that issue and converts to use acpi_dev_put().
Changelog v2:
- split Intel drivers out from others (Pierre)
- sent with cover letter (Mark)
Andy Shevchenko (5):
ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after
use
ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after
use
ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after
use
ASoC: Intel: bytcr_wm5102: Drop reference count of ACPI device after
use
ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use
sound/soc/intel/boards/bytcht_es8316.c | 20 ++++++++++++-------- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++------ sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/bytcr_wm5102.c | 2 +- sound/soc/intel/boards/sof_es8336.c | 14 ++++++++------ 5 files changed, 28 insertions(+), 22 deletions(-)
Signature · 1 line
2.39.0
PATCH v2 1/5 ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after use
Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place.
While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev().
--- sound/soc/intel/boards/bytcht_es8316.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
sound/soc/intel/boards/bytcht_es8316.c +12 -8
@@ -497,21 +497,28 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)if (adev) {snprintf (codec_name,sizeof (codec_name),"i2c-%s" ,acpi_dev_name (adev)); -put_device (&adev->dev); byt_cht_es8316_dais[dai_index].codecs->name = codec_name; }else {dev_err (dev,"Error cannot find '%s' dev\n" , mach->id);return -ENXIO ; } + codec_dev =acpi_get_first_physical_node (adev); +acpi_dev_put (adev); +if (!codec_dev) +return -EPROBE_DEFER ; + priv->codec_dev =get_device (codec_dev); +/* override platform name, if required */ byt_cht_es8316_card.dev = dev; platform_name = mach->mach_params.platform; ret =snd_soc_fixup_dai_links_platform_name (&byt_cht_es8316_card, platform_name); -if (ret) +if (ret) { +put_device (codec_dev);return ret; + }/* Check for BYTCR or other platform and setup quirks */ dmi_id =dmi_first_match (byt_cht_es8316_quirk_table);
@@ -539,13 +546,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)/* get the clock */ priv->mclk =devm_clk_get (dev,"pmc_plt_clk_3" ); -if (IS_ERR (priv->mclk)) +if (IS_ERR (priv->mclk)) { +put_device (codec_dev);return dev_err_probe (dev,PTR_ERR (priv->mclk),"clk_get pmc_plt_clk_3 failed\n" ); - - codec_dev =acpi_get_first_physical_node (adev); -if (!codec_dev) -return -EPROBE_DEFER ; - priv->codec_dev =get_device (codec_dev); + }if (quirk &BYT_CHT_ES8316_JD_INVERTED ) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );
Signature · 1 line
2.39.0
PATCH v2 2/5 ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after use
In reply to Andy ShevchenkoTheoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place.
While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev().
--- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
@@ -922,7 +922,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)if (adev) {snprintf (byt_rt5651_codec_name,sizeof (byt_rt5651_codec_name),"i2c-%s" ,acpi_dev_name (adev)); -put_device (&adev->dev); byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name; }else {dev_err (dev,"Error cannot find '%s' dev\n" , mach->id);
@@ -930,6 +929,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) } codec_dev =acpi_get_first_physical_node (adev); +acpi_dev_put (adev);if (!codec_dev)return -EPROBE_DEFER ; priv->codec_dev =get_device (codec_dev);
Signature · 1 line
2.39.0
PATCH v2 3/5 ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after use
In reply to Andy ShevchenkoTheoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place.
While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev().
--- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/intel/boards/bytcr_rt5640.c +6 -6
@@ -1636,13 +1636,18 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)if (adev) {snprintf (byt_rt5640_codec_name,sizeof (byt_rt5640_codec_name),"i2c-%s" ,acpi_dev_name (adev)); -put_device (&adev->dev); byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name; }else {dev_err (dev,"Error cannot find '%s' dev\n" , mach->id);return -ENXIO ; } + codec_dev =acpi_get_first_physical_node (adev); +acpi_dev_put (adev); +if (!codec_dev) +return -EPROBE_DEFER ; + priv->codec_dev =get_device (codec_dev); +/* * swap SSP0 if bytcr is detected * (will be overridden if DMI quirk is detected)
@@ -1717,11 +1722,6 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) byt_rt5640_quirk = quirk_override; } - codec_dev =acpi_get_first_physical_node (adev); -if (!codec_dev) -return -EPROBE_DEFER ; - priv->codec_dev =get_device (codec_dev); -if (byt_rt5640_quirk &BYT_RT5640_JD_HP_ELITEP_1000G2 ) {acpi_dev_add_driver_gpios (ACPI_COMPANION (priv->codec_dev), byt_rt5640_hp_elitepad_1000g2_gpios);
Signature · 1 line
2.39.0
PATCH v2 4/5 ASoC: Intel: bytcr_wm5102: Drop reference count of ACPI device after use
In reply to Andy ShevchenkoTheoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place.
While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev().
--- sound/soc/intel/boards/bytcr_wm5102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/boards/bytcr_wm5102.c +1 -1
@@ -411,9 +411,9 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)return -ENOENT ; }snprintf (codec_name,sizeof (codec_name),"spi-%s" ,acpi_dev_name (adev)); -put_device (&adev->dev); codec_dev =bus_find_device_by_name (&spi_bus_type,NULL , codec_name); +acpi_dev_put (adev);if (!codec_dev)return -EPROBE_DEFER ;
Signature · 1 line
2.39.0
PATCH v2 5/5 ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use
In reply to Andy ShevchenkoTheoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place.
While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev().
--- sound/soc/intel/boards/sof_es8336.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
sound/soc/intel/boards/sof_es8336.c +8 -6
@@ -681,7 +681,6 @@ static int sof_es8336_probe(struct platform_device *pdev)if (adev) {snprintf (codec_name,sizeof (codec_name),"i2c-%s" ,acpi_dev_name (adev)); -put_device (&adev->dev); dai_links[0 ].codecs->name = codec_name;/* also fixup codec dai name if relevant */
@@ -692,16 +691,19 @@ static int sof_es8336_probe(struct platform_device *pdev)return -ENXIO ; } - ret =snd_soc_fixup_dai_links_platform_name (&sof_es8336_card, - mach->mach_params.platform); -if (ret) -return ret; - codec_dev =acpi_get_first_physical_node (adev); +acpi_dev_put (adev);if (!codec_dev)return -EPROBE_DEFER ; priv->codec_dev =get_device (codec_dev); + ret =snd_soc_fixup_dai_links_platform_name (&sof_es8336_card, + mach->mach_params.platform); +if (ret) { +put_device (codec_dev); +return ret; + } +if (quirk &SOF_ES8336_JD_INVERTED ) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );
Signature · 1 line
2.39.0
Quoted 5 lines · Andy Shevchenko
While looking for the open coded
put_device(&adev->dev)cases, where adev stands for ACPI device, I noticed that in a few ASoC Intel driver, among others, the refcount is not balanced properly in some cases.This series fixes that issue and converts to use
acpi_dev_put().
Thanks Andy!
Quoted 23 lines
Changelog v2:
- split Intel drivers out from others (Pierre)
- sent with cover letter (Mark)Andy Shevchenko (5):
ASoC: Intel:bytcht_es8316: Drop reference count of ACPI device after
use
ASoC: Intel:bytcr_rt5651: Drop reference count of ACPI device after
use
ASoC: Intel:bytcr_rt5640: Drop reference count of ACPI device after
use
ASoC: Intel:bytcr_wm5102: Drop reference count of ACPI device after
use
ASoC: Intel:sof_es8336: Drop reference count of ACPI device after usesound/soc/intel/boards/bytcht_es8316.c | 20 ++++++++++++-------- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++------ sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/bytcr_wm5102.c | 2 +- sound/soc/intel/boards/sof_es8336.c | 14 ++++++++------ 5 files changed, 28 insertions(+), 22 deletions(-)
Mark Brown
maintainerQuoted 11 lines · Andy Shevchenko
While looking for the open coded
put_device(&adev->dev)cases, where adev stands for ACPI device, I noticed that in a few ASoC Intel driver, among others, the refcount is not balanced properly in some cases.This series fixes that issue and converts to use
acpi_dev_put().Changelog v2:
- split Intel drivers out from others (Pierre)
- sent with cover letter (Mark)[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after use
commit: 6b1c0bd6fdefbf3c3d75680c2708f5423ef72e46
[2/5] ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after use
commit: 721858823d7cdc8f2a897579b040e935989f6f02
[3/5] ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after use
commit: cbf87bcf46e399e9a5288430d940efbad3551c68
[4/5] ASoC: Intel: bytcr_wm5102: Drop reference count of ACPI device after use
commit: c8aa49abdeda2ab587aadb083e670f6aa0236f93
[5/5] ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use
commit: 64e57b2195725c1ae2246a8a2ce224abb60620acAll 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