Browse Source

audio-lnx: asoc: sdm660: fix rmmod issue with gpio_free

Check if GPIO is valid before free to avoid crash.

Change-Id: Ie052e5ff1776ad57ae9c1d0f00873ba29e11f78f
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 7 years ago
parent
commit
c4ef3b5eca
1 changed files with 12 additions and 3 deletions
  1. 12 3
      asoc/sdm660-common.c

+ 12 - 3
asoc/sdm660-common.c

@@ -3353,9 +3353,18 @@ static int msm_asoc_machine_remove(struct platform_device *pdev)
 	if (pdata->snd_card_val == INT_SND_CARD)
 		mutex_destroy(&pdata->cdc_int_mclk0_mutex);
 
-	gpio_free(pdata->us_euro_gpio);
-	gpio_free(pdata->hph_en1_gpio);
-	gpio_free(pdata->hph_en0_gpio);
+	if (gpio_is_valid(pdata->us_euro_gpio)) {
+		gpio_free(pdata->us_euro_gpio);
+		pdata->us_euro_gpio = 0;
+	}
+	if (gpio_is_valid(pdata->hph_en1_gpio)) {
+		gpio_free(pdata->hph_en1_gpio);
+		pdata->hph_en1_gpio = 0;
+	}
+	if (gpio_is_valid(pdata->hph_en0_gpio)) {
+		gpio_free(pdata->hph_en0_gpio);
+		pdata->hph_en0_gpio = 0;
+	}
 
 	if (pdata->snd_card_val != INT_SND_CARD)
 		audio_notifier_deregister("sdm660");