linux/sound
Jarkko Nikula b56f12b3ab ASoC: dapm: Fix widget double free with auto-disable DAPM kcontrol
commit 2697e4fb92 upstream.

Commit 9e1fda4ae158 ("ASoC: dapm: Implement mixer input auto-disable")
is trying to free the widget it allocated by snd_soc_dapm_new_control()
call in dapm_kcontrol_data_alloc() by adding kfree(data->widget) to
dapm_kcontrol_free().

This is causing a widget double free with auto-disabled DAPM kcontrols
in sound card unregistration because widgets are already freed before
dapm_kcontrol_free() is called.

Reason for that is all widgets are added into dapm->card->widgets list
in snd_soc_dapm_new_control() and freed in dapm_free_widgets() during
execution of snd_soc_dapm_free().

Now snd_soc_dapm_free() calls for different DAPM contexts happens before
snd_card_free() call from where the call chain to dapm_kcontrol_free()
begins:

soc_cleanup_card_resources()
  soc_remove_dai_links()
    soc_remove_link_dais()
      snd_soc_dapm_free(&cpu_dai->dapm)
    soc_remove_link_components()
      soc_remove_platform()
        snd_soc_dapm_free(&platform->dapm)
      soc_remove_codec()
        snd_soc_dapm_free(&codec->dapm)
  snd_soc_dapm_free(&card->dapm)
  snd_card_free()
    snd_card_do_free()
      snd_device_free_all()
        snd_device_free()
          snd_ctl_dev_free()
            snd_ctl_remove()
              snd_ctl_free_one()
                dapm_kcontrol_free()

This wasn't making harm with ordinary DAPM kcontrols since data->widget is NULL for
them.

Fixes: 9e1fda4ae158 (ASoC: dapm: Implement mixer input auto-disable)
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-13 13:32:49 +02:00
..
aoa sound fixes for 3.13-rc1 2013-11-16 12:50:53 -08:00
arm ALSA: AACI: Convert to modern PM ops 2013-12-03 17:43:42 +01:00
atmel Merge branch 'for-linus' into for-next 2013-12-16 15:53:52 +01:00
core ALSA: compress: Pass through return value of open ops callback 2014-03-19 15:46:24 +01:00
drivers ALSA: pcsp: Fix the order of input device unregistration 2013-11-14 15:50:10 +01:00
firewire ALSA: dice: fix array limits in dice_proc_read() 2013-11-29 10:23:04 +01:00
i2c ALSA: ak4114: Fix wrong register array size 2013-10-29 16:42:36 +01:00
isa ALSA: isa: not allocating enough space 2013-11-13 09:28:31 +01:00
mips ALSA: mips/ad1843: Use WARN_ON() instead of BUG_ON() 2013-11-06 08:35:16 +01:00
oss sound: oss: remove last sleep_on users 2014-01-14 16:12:07 +01:00
parisc ALSA: Remove the rest of *_set_drvdata(NULL) calls 2013-05-29 12:50:59 +02:00
pci ALSA: hda/realtek - Add headset Mic support for Dell machine 2014-05-06 07:59:24 -07:00
pcmcia sound/pcmcia: use module_pcmcia_driver() in pcmcia drivers 2013-03-15 12:26:39 -07:00
ppc Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2013-11-18 15:50:07 -08:00
sh ALSA: sh_dac_audio: Remove redundant platform_set_drvdata() 2013-05-23 14:36:45 +02:00
soc ASoC: dapm: Fix widget double free with auto-disable DAPM kcontrol 2014-05-13 13:32:49 +02:00
sparc ALSA: sparc: fix missing unlock on error in snd_cs4231_playback_prepare() 2013-11-11 16:23:16 +01:00
spi ALSA: at73c213: clk_round_rate() can return a zero upon error 2013-12-10 21:19:47 +01:00
synth
usb ALSA: usb-audio: Add quirk for Logitech Webcam C500 2014-03-05 12:37:15 +01:00
Kconfig sound: remove reference to feature-removal-schedule.txt 2012-12-17 17:15:12 -08:00
Makefile
ac97_bus.c
last.c ALSA: Remove the last mention of SNDRV_MAIN_OBJECT_FILE 2012-09-03 10:07:23 +02:00
sound_core.c consolidate the reassignments of ->f_op in ->open() instances 2013-10-24 23:34:53 -04:00
sound_firmware.c sound_firmware: don't bother with filp_close() 2013-04-09 15:16:32 -04:00