Skip to content

Commit 5366a64

Browse files
brentlubroonie
authored andcommitted
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>
1 parent d1cf5d3 commit 5366a64

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sound/soc/codecs/rt5645.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,13 +3269,17 @@ static int rt5645_component_set_jack(struct snd_soc_component *component,
32693269
{
32703270
struct snd_soc_jack *mic_jack = NULL;
32713271
struct snd_soc_jack *btn_jack = NULL;
3272-
int *type = (int *)data;
3272+
int type;
32733273

3274-
if (*type & SND_JACK_MICROPHONE)
3275-
mic_jack = hs_jack;
3276-
if (*type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 |
3277-
SND_JACK_BTN_2 | SND_JACK_BTN_3))
3278-
btn_jack = hs_jack;
3274+
if (hs_jack) {
3275+
type = *(int *)data;
3276+
3277+
if (type & SND_JACK_MICROPHONE)
3278+
mic_jack = hs_jack;
3279+
if (type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 |
3280+
SND_JACK_BTN_2 | SND_JACK_BTN_3))
3281+
btn_jack = hs_jack;
3282+
}
32793283

32803284
return rt5645_set_jack_detect(component, hs_jack, mic_jack, btn_jack);
32813285
}

0 commit comments

Comments
 (0)