OSDN Git Service

ASoC: wcd-mbhc: add null pointer check
authordojha <dojha@codeaurora.org>
Tue, 26 Apr 2016 11:32:41 +0000 (17:02 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Fri, 6 Jan 2017 05:31:40 +0000 (21:31 -0800)
Crash observed during headset detection because of a null pointer
access. So check for pointer not being null prior access.

CRs-Fixed: 1010966
Change-Id: I097c077317a3082121dc9b0f553b9538b5fb75ae
Signed-off-by: dojha <dojha@codeaurora.org>
sound/soc/codecs/wcd-mbhc-v2.c

index 0549b23..319a30b 100644 (file)
@@ -1234,7 +1234,8 @@ correct_plug_type:
                                        mbhc->hs_detect_work_stop);
                        wcd_enable_curr_micbias(mbhc,
                                                WCD_MBHC_EN_NONE);
-                       if (mbhc->micbias_enable) {
+                       if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
+                               mbhc->micbias_enable) {
                                mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
                                        mbhc->codec, MIC_BIAS_2, false);
                                if (mbhc->mbhc_cb->set_micbias_value)
@@ -1259,7 +1260,8 @@ correct_plug_type:
                                        mbhc->hs_detect_work_stop);
                        wcd_enable_curr_micbias(mbhc,
                                                WCD_MBHC_EN_NONE);
-                       if (mbhc->micbias_enable) {
+                       if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
+                               mbhc->micbias_enable) {
                                mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
                                        mbhc->codec, MIC_BIAS_2, false);
                                if (mbhc->mbhc_cb->set_micbias_value)