ASoC: Intel: avs: nau8825: Add null pointer check for snd_soc_card_get_codec_dai()
Subsystems (4)
PATCH 1/1 ASoC: Intel: avs: nau8825: Add null pointer check for snd_soc_card_get_codec_dai()
The function avs_card_suspend_pre() in nau8825 calls the function snd_soc_card_get_codec_dai(), but does not check its return value which is a null pointer if the function fails. This can result in a null pointer dereference. A proper implementation can be found in acp5x_nau8821_hw_params() and card_suspend_pre().
Add a null pointer check for snd_soc_card_get_codec_dai() to avoid null pointer dereference when the function fails.
--- sound/soc/intel/avs/boards/nau8825.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/intel/avs/boards/nau8825.c +5 -0
@@ -220,6 +220,11 @@ static int avs_card_suspend_pre(struct snd_soc_card *card) {struct snd_soc_dai *codec_dai =snd_soc_card_get_codec_dai (card,SKL_NUVOTON_CODEC_DAI ); +if (!codec_dai) { +dev_err (card->dev,"Codec dai not found\n" ); +return -EINVAL ; + } +return snd_soc_component_set_jack (codec_dai->component,NULL ,NULL ); }
Signature · 1 line
2.42.0.windows.2
Quoted 22 lines · Wentao Liang
The function
avs_card_suspend_pre()in nau8825 calls the functionsnd_soc_card_get_codec_dai(), but does not check its return value which is a null pointer if the function fails. This can result in a null pointer dereference. A proper implementation can be found inacp5x_nau8821_hw_params()andcard_suspend_pre().Add a null pointer check for
snd_soc_card_get_codec_dai()to avoid null pointer dereference when the function fails.Fixes 9febcd7a0180 ("ASoC: Intel: avs: nau8825: Refactor jack handling")Cc [email protected] # v6.2Signed-off-by Wentao Liang <[email protected]>--- sound/soc/intel/avs/boards/nau8825.c | 5 +++++ 1 file changed, 5 insertions(+)sound/soc/intel/avs/boards/nau8825.c +0
-0@@ -220,6 +220,11 @@ static int avs_card_suspend_pre(struct snd_soc_card *card) {
sound/soc/intel/avs/boards/nau8825.c static int avs_card_suspend_pre(struct snd_soc_card *card) · line 230
Quoted 10 lines
sound/soc/intel/avs/boards/nau8825.c +5
-0struct snd_soc_dai *codec_dai =snd_soc_card_get_codec_dai (card,SKL_NUVOTON_CODEC_DAI ); +if (!codec_dai) { +dev_err (card->dev,"Codec dai not found\n" ); +return -EINVAL ; + } +return snd_soc_component_set_jack (codec_dai->component,NULL ,NULL ); }
Same as in other case, where Cezary commented - this is not needed, once card is loaded codec should exist.