[PATCH v3 3/4] ASoC: codecs: wcd-mbhc: guard against NULL cfg in typec_report_(un)plug
From: Val Packett
Date: Tue Oct 20 2026 - 13:11:41 EST
mbhc->cfg is only set by wcd_mbhc_start() which is called by the codec's
set_jack op. wcd_mbhc_typec_report_plug/unplug are called by the platform
device's typec callbacks, which are not synchronized with codec ops, so
a hotplug could be reported before set_jack was called. Though unlikely
to happen in practice, add a check to be safe.
Found by sashiko-bot via review of wcd937x Type-C integration patches.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 0c105997eefd ("ASoC: codec: wcd-mbhc-v2: add support when connected behind an USB-C audio mux")
Reviewed-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
Signed-off-by: Val Packett <val@xxxxxxxxxxxx>
---
sound/soc/codecs/wcd-mbhc-v2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index 850be84d65ce..fd40c1686d66 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -594,7 +594,7 @@ static irqreturn_t wcd_mbhc_mech_plug_detect_irq(int irq, void *data)
int wcd_mbhc_typec_report_unplug(struct wcd_mbhc *mbhc)
{
- if (!mbhc || !mbhc->cfg->typec_analog_mux)
+ if (!mbhc || !mbhc->cfg || !mbhc->cfg->typec_analog_mux)
return -EINVAL;
if (mbhc->mbhc_cb->clk_setup)
@@ -611,7 +611,7 @@ EXPORT_SYMBOL_GPL(wcd_mbhc_typec_report_unplug);
int wcd_mbhc_typec_report_plug(struct wcd_mbhc *mbhc)
{
- if (!mbhc || !mbhc->cfg->typec_analog_mux)
+ if (!mbhc || !mbhc->cfg || !mbhc->cfg->typec_analog_mux)
return -EINVAL;
if (mbhc->mbhc_cb->clk_setup)
--
2.55.0