Commit 7d99a70b authored by Hans de Goede's avatar Hans de Goede Committed by Mark Brown

ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT boards

Since commit 13f58267 ("ASoC: soc.h: don't create dummy Component
via COMP_DUMMY()") dummy snd_soc_dai_link.codecs entries no longer
have a name set.

This means that when looking for the codec dai_link the machine
driver can no longer unconditionally run strcmp() on
snd_soc_dai_link.codecs[0].name since this may now be NULL.

Add a check for snd_soc_dai_link.codecs[0].name being NULL to all
BYT/CHT machine drivers to avoid NULL pointer dereferences in
their probe() methods.

Fixes: 13f58267 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()")
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240210134400.24913-2-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 727b9432
...@@ -241,7 +241,8 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev) ...@@ -241,7 +241,8 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_cht_cx2072x_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_cht_cx2072x_dais); i++) {
if (!strcmp(byt_cht_cx2072x_dais[i].codecs->name, if (byt_cht_cx2072x_dais[i].codecs->name &&
!strcmp(byt_cht_cx2072x_dais[i].codecs->name,
"i2c-14F10720:00")) { "i2c-14F10720:00")) {
dai_index = i; dai_index = i;
break; break;
......
...@@ -245,7 +245,8 @@ static int bytcht_da7213_probe(struct platform_device *pdev) ...@@ -245,7 +245,8 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(dailink); i++) { for (i = 0; i < ARRAY_SIZE(dailink); i++) {
if (!strcmp(dailink[i].codecs->name, "i2c-DLGS7213:00")) { if (dailink[i].codecs->name &&
!strcmp(dailink[i].codecs->name, "i2c-DLGS7213:00")) {
dai_index = i; dai_index = i;
break; break;
} }
......
...@@ -546,7 +546,8 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) ...@@ -546,7 +546,8 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
if (!strcmp(byt_cht_es8316_dais[i].codecs->name, if (byt_cht_es8316_dais[i].codecs->name &&
!strcmp(byt_cht_es8316_dais[i].codecs->name,
"i2c-ESSX8316:00")) { "i2c-ESSX8316:00")) {
dai_index = i; dai_index = i;
break; break;
......
...@@ -1652,7 +1652,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ...@@ -1652,7 +1652,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
if (!strcmp(byt_rt5640_dais[i].codecs->name, if (byt_rt5640_dais[i].codecs->name &&
!strcmp(byt_rt5640_dais[i].codecs->name,
"i2c-10EC5640:00")) { "i2c-10EC5640:00")) {
dai_index = i; dai_index = i;
break; break;
......
...@@ -910,7 +910,8 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ...@@ -910,7 +910,8 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_rt5651_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_rt5651_dais); i++) {
if (!strcmp(byt_rt5651_dais[i].codecs->name, if (byt_rt5651_dais[i].codecs->name &&
!strcmp(byt_rt5651_dais[i].codecs->name,
"i2c-10EC5651:00")) { "i2c-10EC5651:00")) {
dai_index = i; dai_index = i;
break; break;
......
...@@ -605,7 +605,8 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev) ...@@ -605,7 +605,8 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)
/* find index of codec dai */ /* find index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_wm5102_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_wm5102_dais); i++) {
if (!strcmp(byt_wm5102_dais[i].codecs->name, if (byt_wm5102_dais[i].codecs->name &&
!strcmp(byt_wm5102_dais[i].codecs->name,
"wm5102-codec")) { "wm5102-codec")) {
dai_index = i; dai_index = i;
break; break;
......
...@@ -571,7 +571,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev) ...@@ -571,7 +571,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
/* set correct codec name */ /* set correct codec name */
for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
if (!strcmp(card->dai_link[i].codecs->name, if (card->dai_link[i].codecs->name &&
!strcmp(card->dai_link[i].codecs->name,
"i2c-10EC5645:00")) { "i2c-10EC5645:00")) {
card->dai_link[i].codecs->name = drv->codec_name; card->dai_link[i].codecs->name = drv->codec_name;
dai_index = i; dai_index = i;
......
...@@ -466,7 +466,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev) ...@@ -466,7 +466,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
/* find index of codec dai */ /* find index of codec dai */
for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) { for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) {
if (!strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) { if (cht_dailink[i].codecs->name &&
!strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) {
dai_index = i; dai_index = i;
break; break;
} }
......
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