Skip to content

Commit 8c41be2

Browse files
committed
ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT
Merge series from Hans de Goede <hdegoede@redhat.com>: While testing 6.8 on a Bay Trail device with a ALC5640 codec I noticed a regression in 6.8 which causes a NULL pointer deref in probe(). All BYT/CHT Intel machine drivers are affected. Patch 1/2 of this series fixes all of them. Patch 2/2 adds some small cleanups to cht_bsw_rt5645.c for issues which I noticed while working on 1/2.
2 parents c4b603c + 930375d commit 8c41be2

8 files changed

Lines changed: 17 additions & 11 deletions

File tree

sound/soc/intel/boards/bytcht_cx2072x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
241241

242242
/* fix index of codec dai */
243243
for (i = 0; i < ARRAY_SIZE(byt_cht_cx2072x_dais); i++) {
244-
if (!strcmp(byt_cht_cx2072x_dais[i].codecs->name,
244+
if (byt_cht_cx2072x_dais[i].codecs->name &&
245+
!strcmp(byt_cht_cx2072x_dais[i].codecs->name,
245246
"i2c-14F10720:00")) {
246247
dai_index = i;
247248
break;

sound/soc/intel/boards/bytcht_da7213.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
245245

246246
/* fix index of codec dai */
247247
for (i = 0; i < ARRAY_SIZE(dailink); i++) {
248-
if (!strcmp(dailink[i].codecs->name, "i2c-DLGS7213:00")) {
248+
if (dailink[i].codecs->name &&
249+
!strcmp(dailink[i].codecs->name, "i2c-DLGS7213:00")) {
249250
dai_index = i;
250251
break;
251252
}

sound/soc/intel/boards/bytcht_es8316.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
546546

547547
/* fix index of codec dai */
548548
for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
549-
if (!strcmp(byt_cht_es8316_dais[i].codecs->name,
549+
if (byt_cht_es8316_dais[i].codecs->name &&
550+
!strcmp(byt_cht_es8316_dais[i].codecs->name,
550551
"i2c-ESSX8316:00")) {
551552
dai_index = i;
552553
break;

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
16521652

16531653
/* fix index of codec dai */
16541654
for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
1655-
if (!strcmp(byt_rt5640_dais[i].codecs->name,
1655+
if (byt_rt5640_dais[i].codecs->name &&
1656+
!strcmp(byt_rt5640_dais[i].codecs->name,
16561657
"i2c-10EC5640:00")) {
16571658
dai_index = i;
16581659
break;

sound/soc/intel/boards/bytcr_rt5651.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
910910

911911
/* fix index of codec dai */
912912
for (i = 0; i < ARRAY_SIZE(byt_rt5651_dais); i++) {
913-
if (!strcmp(byt_rt5651_dais[i].codecs->name,
913+
if (byt_rt5651_dais[i].codecs->name &&
914+
!strcmp(byt_rt5651_dais[i].codecs->name,
914915
"i2c-10EC5651:00")) {
915916
dai_index = i;
916917
break;

sound/soc/intel/boards/bytcr_wm5102.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)
605605

606606
/* find index of codec dai */
607607
for (i = 0; i < ARRAY_SIZE(byt_wm5102_dais); i++) {
608-
if (!strcmp(byt_wm5102_dais[i].codecs->name,
608+
if (byt_wm5102_dais[i].codecs->name &&
609+
!strcmp(byt_wm5102_dais[i].codecs->name,
609610
"wm5102-codec")) {
610611
dai_index = i;
611612
break;

sound/soc/intel/boards/cht_bsw_rt5645.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct cht_acpi_card {
4040
struct cht_mc_private {
4141
struct snd_soc_jack jack;
4242
struct cht_acpi_card *acpi_card;
43-
char codec_name[SND_ACPI_I2C_ID_LEN];
4443
struct clk *mclk;
4544
};
4645

@@ -567,14 +566,14 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
567566
}
568567

569568
card->dev = &pdev->dev;
570-
sprintf(drv->codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
571569

572570
/* set correct codec name */
573571
for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
574-
if (!strcmp(card->dai_link[i].codecs->name,
572+
if (cht_dailink[i].codecs->name &&
573+
!strcmp(cht_dailink[i].codecs->name,
575574
"i2c-10EC5645:00")) {
576-
card->dai_link[i].codecs->name = drv->codec_name;
577575
dai_index = i;
576+
break;
578577
}
579578

580579
/* fixup codec name based on HID */

sound/soc/intel/boards/cht_bsw_rt5672.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
466466

467467
/* find index of codec dai */
468468
for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) {
469-
if (!strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) {
469+
if (cht_dailink[i].codecs->name &&
470+
!strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) {
470471
dai_index = i;
471472
break;
472473
}

0 commit comments

Comments
 (0)