diff mbox series

[10/11] ASoC: codecs: rt298: Fix NULL jack in interrupt

Message ID 20220609133541.3984886-11-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series ASoC: codecs: Series of fixes for realtek codecs used on RVPs | expand

Commit Message

Amadeusz Sławiński June 9, 2022, 1:35 p.m. UTC
Set rt298->jack to passed value in mic_detect, otherwise when jack is
set to NULL on next interrupt call, we may use freed pointer.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/codecs/rt298.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Mark Brown June 9, 2022, 2:19 p.m. UTC | #1
On Thu, Jun 09, 2022 at 03:35:40PM +0200, Amadeusz Sławiński wrote:
> Set rt298->jack to passed value in mic_detect, otherwise when jack is
> set to NULL on next interrupt call, we may use freed pointer.

This is an actual fix so should go towards the start of the series,
putting fixes at the start of the series avoids them getting spurious
dependencies.
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 3c13b6dc3be9..2af037536bc9 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -336,6 +336,8 @@  static int rt298_mic_detect(struct snd_soc_component *component,
 	bool mic = false;
 	int status = 0;
 
+	rt298->jack = jack;
+
 	/* If jack in NULL, disable HS jack */
 	if (!jack) {
 		disable_irq(rt298->i2c->irq);
@@ -346,7 +348,6 @@  static int rt298_mic_detect(struct snd_soc_component *component,
 		return 0;
 	}
 
-	rt298->jack = jack;
 	regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
 	enable_irq(rt298->i2c->irq);