]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: rt7*-sdw: harden jack_detect_handler
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 6 Jun 2022 20:37:50 +0000 (15:37 -0500)
committerMark Brown <broonie@kernel.org>
Fri, 24 Jun 2022 15:21:33 +0000 (16:21 +0100)
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: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220606203752.144159-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt700.c
sound/soc/codecs/rt711-sdca.c
sound/soc/codecs/rt711.c

index af32295fa9b939a39a8e66434ade078515543eb1..4a99d5f4706fd975a4cdac7b1a698fe1d42a4f45 100644 (file)
@@ -162,7 +162,7 @@ static void rt700_jack_detect_handler(struct work_struct *work)
        if (!rt700->hs_jack)
                return;
 
-       if (!rt700->component->card->instantiated)
+       if (!rt700->component->card || !rt700->component->card->instantiated)
                return;
 
        reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT;
index af73bcb4560a3fe8a6cca133abccc078a5f51b57..93b36f05cb567a489d54d9ae5db3b6b1bcc43865 100644 (file)
@@ -294,7 +294,7 @@ static void rt711_sdca_jack_detect_handler(struct work_struct *work)
        if (!rt711->hs_jack)
                return;
 
-       if (!rt711->component->card->instantiated)
+       if (!rt711->component->card || !rt711->component->card->instantiated)
                return;
 
        /* SDW_SCP_SDCA_INT_SDCA_0 is used for jack detection */
index 1e35ba433a7e7594e504285eb440cf17c6551378..2f445b27305a45f949f59ed79192c4839c337680 100644 (file)
@@ -242,7 +242,7 @@ static void rt711_jack_detect_handler(struct work_struct *work)
        if (!rt711->hs_jack)
                return;
 
-       if (!rt711->component->card->instantiated)
+       if (!rt711->component->card || !rt711->component->card->instantiated)
                return;
 
        if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {