UPSTREAM: ASoC: dapm: Fix kcontrol widget name memory management

The name field of the widget template is only used inside
snd_soc_dapm_new_control_unlocked() which allocates a copy for the actual
widget. This means we need to free the name allocated for the template in
dapm_kcontrol_data_alloc() and not the name of the actual widget in
dapm_kcontrol_free(). Otherwise we get a double free on the widget name and
a memory leak on the template name.

Fixes: 773da9b358bf ("ASoC: dapm: Append "Autodisable" to autodisable widget names")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit e18077b6e5dfe26e9fbbdc1fd1085a1701c24bea)
Signed-off-by: Ricky Liang <jcliang@chromium.org>

BUG=chrome-os-partner:59601
TEST=Make sure the kmemleak report does not include leaked objects
     with the patch.

Change-Id: Ifd60ea946e5f4ef2d4d18fbe5d6f00654e83f7ad
Reviewed-on: https://chromium-review.googlesource.com/408839
Commit-Ready: Ricky Liang <jcliang@chromium.org>
Tested-by: Ricky Liang <jcliang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
1 file changed