Skip to content

Commit

Permalink
ASoC: rt5645: NULL pointer access when removing jack
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brent Lu authored and Mark Brown committed Sep 4, 2023
1 parent d1cf5d3 commit 5366a64
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sound/soc/codecs/rt5645.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5366a64

Please sign in to comment.