From c4ef3b5ecaa4161cb7455dfabb77e28ee6d6f188 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Wed, 18 Oct 2017 10:57:15 +0800 Subject: [PATCH] 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 --- asoc/sdm660-common.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/asoc/sdm660-common.c b/asoc/sdm660-common.c index 34fcdf0150ac..1874cfa02860 100644 --- a/asoc/sdm660-common.c +++ b/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");