Skip to content

Commit 14e91dd

Browse files
plbossartbroonie
authored andcommitted
ASoC: Intel: boards: always check the result of acpi_dev_get_first_match_dev()
The code seems mostly copy-pasted, with some machine drivers forgetting to test if the 'adev' result is NULL. Add this check when missing, and use -ENOENT consistently as an error code. Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/alsa-devel/[email protected]/T/#u Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1ab959b commit 14e91dd

File tree

9 files changed

+24
-4
lines changed

9 files changed

+24
-4
lines changed

sound/soc/intel/boards/bytcht_cx2072x.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
255255
snprintf(codec_name, sizeof(codec_name), "i2c-%s",
256256
acpi_dev_name(adev));
257257
byt_cht_cx2072x_dais[dai_index].codecs->name = codec_name;
258+
} else {
259+
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
260+
return -ENOENT;
258261
}
262+
259263
acpi_dev_put(adev);
260264

261265
/* override platform name, if required */

sound/soc/intel/boards/bytcht_da7213.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
258258
snprintf(codec_name, sizeof(codec_name),
259259
"i2c-%s", acpi_dev_name(adev));
260260
dailink[dai_index].codecs->name = codec_name;
261+
} else {
262+
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
263+
return -ENOENT;
261264
}
265+
262266
acpi_dev_put(adev);
263267

264268
/* override platform name, if required */

sound/soc/intel/boards/bytcht_es8316.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
562562
byt_cht_es8316_dais[dai_index].codecs->name = codec_name;
563563
} else {
564564
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
565-
return -ENXIO;
565+
return -ENOENT;
566566
}
567567

568568
codec_dev = acpi_get_first_physical_node(adev);

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
16931693
byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
16941694
} else {
16951695
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
1696-
return -ENXIO;
1696+
return -ENOENT;
16971697
}
16981698

16991699
codec_dev = acpi_get_first_physical_node(adev);

sound/soc/intel/boards/bytcr_rt5651.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
926926
byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name;
927927
} else {
928928
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
929-
return -ENXIO;
929+
return -ENOENT;
930930
}
931931

932932
codec_dev = acpi_get_first_physical_node(adev);

sound/soc/intel/boards/cht_bsw_rt5645.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
582582
snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
583583
"i2c-%s", acpi_dev_name(adev));
584584
cht_dailink[dai_index].codecs->name = cht_rt5645_codec_name;
585+
} else {
586+
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
587+
return -ENOENT;
585588
}
589+
586590
/* acpi_get_first_physical_node() returns a borrowed ref, no need to deref */
587591
codec_dev = acpi_get_first_physical_node(adev);
588592
acpi_dev_put(adev);

sound/soc/intel/boards/cht_bsw_rt5672.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
479479
snprintf(drv->codec_name, sizeof(drv->codec_name),
480480
"i2c-%s", acpi_dev_name(adev));
481481
cht_dailink[dai_index].codecs->name = drv->codec_name;
482+
} else {
483+
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
484+
return -ENOENT;
482485
}
486+
483487
acpi_dev_put(adev);
484488

485489
/* Use SSP0 on Bay Trail CR devices */

sound/soc/intel/boards/sof_es8336.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static int sof_es8336_probe(struct platform_device *pdev)
681681
dai_links[0].codecs->dai_name = "ES8326 HiFi";
682682
} else {
683683
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
684-
return -ENXIO;
684+
return -ENOENT;
685685
}
686686

687687
codec_dev = acpi_get_first_physical_node(adev);

sound/soc/intel/boards/sof_wm8804.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ static int sof_wm8804_probe(struct platform_device *pdev)
270270
snprintf(codec_name, sizeof(codec_name),
271271
"%s%s", "i2c-", acpi_dev_name(adev));
272272
dailink[dai_index].codecs->name = codec_name;
273+
} else {
274+
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
275+
return -ENOENT;
273276
}
277+
274278
acpi_dev_put(adev);
275279

276280
snd_soc_card_set_drvdata(card, ctx);

0 commit comments

Comments
 (0)