Skip to content

Commit

Permalink
ASoC: rt5645: Fix potential crash in jd function
Browse files Browse the repository at this point in the history
If no one defined the rt5645->pdata.hp_det_gpio in coreboot/bios.
It will cause kernel to reboot because rt5645->pdata.hp_det_gpio
is 0. So it is worth to add a check in rt5645_jack_detect.

Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Bard Liao authored and Mark Brown committed Dec 9, 2014
1 parent df078d2 commit 7594589
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/soc/codecs/rt5645.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,10 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec,
int gpio_state, jack_type = 0;
unsigned int val;

if (!gpio_is_valid(rt5645->pdata.hp_det_gpio)) {
dev_err(codec->dev, "invalid gpio\n");
return -EINVAL;
}
gpio_state = gpio_get_value(rt5645->pdata.hp_det_gpio);

dev_dbg(codec->dev, "gpio = %d(%d)\n", rt5645->pdata.hp_det_gpio,
Expand Down

0 comments on commit 7594589

Please sign in to comment.