ASoC: tlv320aic3x: fix reset gpio reference counting
authorPhilipp Puschmann <philipp.puschmann@emlix.com>
Wed, 27 Feb 2019 15:17:33 +0000 (16:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 May 2019 15:54:05 +0000 (17:54 +0200)
commit98a80393b82a3be7bf72a9246196c722851fd74a
treef9be37f952d8cd1c50c7ceb3120198accb4bd075
parent34ae4c6a3609960d4fc4010df7a4b2b877649d00
ASoC: tlv320aic3x: fix reset gpio reference counting

[ Upstream commit 82ad759143ed77673db0d93d53c1cde7b99917ee ]

This patch fixes a bug that prevents freeing the reset gpio on unloading
the module.

aic3x_i2c_probe is called when loading the module and it calls list_add
with a probably uninitialized list entry aic3x->list (next = prev = NULL)).
So even if list_del is called it does nothing and in the end the gpio_reset
is not freed. Then a repeated module probing fails silently because
gpio_request fails.

When moving INIT_LIST_HEAD to aic3x_i2c_probe we also have to move
list_del to aic3x_i2c_remove because aic3x_remove may be called
multiple times without aic3x_i2c_remove being called which leads to
a NULL pointer dereference.

Signed-off-by: Philipp Puschmann <philipp.puschmann@emlix.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/tlv320aic3x.c