Commit 0484271a authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: rt7*-sdw: harden jack_detect_handler

Realtek headset codec drivers typically check if the card is
instantiated before proceeding with the jack detection.

The rt700, rt711 and rt711-sdca are however missing a check on the
card pointer, which can lead to NULL dereferences encountered in
driver bind/unbind tests.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220606203752.144159-6-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 08bb5dc6
...@@ -162,7 +162,7 @@ static void rt700_jack_detect_handler(struct work_struct *work) ...@@ -162,7 +162,7 @@ static void rt700_jack_detect_handler(struct work_struct *work)
if (!rt700->hs_jack) if (!rt700->hs_jack)
return; return;
if (!rt700->component->card->instantiated) if (!rt700->component->card || !rt700->component->card->instantiated)
return; return;
reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT;
......
...@@ -294,7 +294,7 @@ static void rt711_sdca_jack_detect_handler(struct work_struct *work) ...@@ -294,7 +294,7 @@ static void rt711_sdca_jack_detect_handler(struct work_struct *work)
if (!rt711->hs_jack) if (!rt711->hs_jack)
return; return;
if (!rt711->component->card->instantiated) if (!rt711->component->card || !rt711->component->card->instantiated)
return; return;
/* SDW_SCP_SDCA_INT_SDCA_0 is used for jack detection */ /* SDW_SCP_SDCA_INT_SDCA_0 is used for jack detection */
......
...@@ -242,7 +242,7 @@ static void rt711_jack_detect_handler(struct work_struct *work) ...@@ -242,7 +242,7 @@ static void rt711_jack_detect_handler(struct work_struct *work)
if (!rt711->hs_jack) if (!rt711->hs_jack)
return; return;
if (!rt711->component->card->instantiated) if (!rt711->component->card || !rt711->component->card->instantiated)
return; return;
if (pm_runtime_status_suspended(rt711->slave->dev.parent)) { if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment