summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorBrent Lu <brent.lu@intel.com>2023-09-04 18:40:46 +0800
committerMark Brown <broonie@kernel.org>2023-09-04 13:32:58 +0100
commit5366a64033ef46d7fc36db097d4bde12af22c405 (patch)
treed4a112f4dd84f9dab4474641085a1e65ed7f2d26 /sound
parentd1cf5d30b43f1a331032ebf3e11d9e366ab0f885 (diff)
downloadlinux-stable-5366a64033ef46d7fc36db097d4bde12af22c405.tar.gz
linux-stable-5366a64033ef46d7fc36db097d4bde12af22c405.tar.bz2
linux-stable-5366a64033ef46d7fc36db097d4bde12af22c405.zip
ASoC: rt5645: NULL pointer access when removing jack
Machine driver calls snd_soc_component_set_jack() function with NULL jack and data parameters when removing jack in codec exit function. Do not access data when jack is NULL. Signed-off-by: Brent Lu <brent.lu@intel.com> Link: https://lore.kernel.org/r/20230904104046.4150208-1-brent.lu@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rt5645.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 038d93e20883..1a137ca3f496 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3269,13 +3269,17 @@ static int rt5645_component_set_jack(struct snd_soc_component *component,
{
struct snd_soc_jack *mic_jack = NULL;
struct snd_soc_jack *btn_jack = NULL;
- int *type = (int *)data;
+ int type;
- if (*type & SND_JACK_MICROPHONE)
- mic_jack = hs_jack;
- if (*type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 |
- SND_JACK_BTN_2 | SND_JACK_BTN_3))
- btn_jack = hs_jack;
+ if (hs_jack) {
+ type = *(int *)data;
+
+ if (type & SND_JACK_MICROPHONE)
+ mic_jack = hs_jack;
+ if (type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+ SND_JACK_BTN_2 | SND_JACK_BTN_3))
+ btn_jack = hs_jack;
+ }
return rt5645_set_jack_detect(component, hs_jack, mic_jack, btn_jack);
}