]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: Intel: boards: always check the result of acpi_dev_get_first_match_dev()
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 27 Aug 2024 12:32:01 +0000 (20:32 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 28 Aug 2024 12:01:53 +0000 (13:01 +0100)
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 <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/alsa-devel/918944d2-3d00-465e-a9d1-5d57fc966113@stanley.mountain/T/#u
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://patch.msgid.link/20240827123215.258859-4-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/bytcht_cx2072x.c
sound/soc/intel/boards/bytcht_da7213.c
sound/soc/intel/boards/bytcht_es8316.c
sound/soc/intel/boards/bytcr_rt5640.c
sound/soc/intel/boards/bytcr_rt5651.c
sound/soc/intel/boards/cht_bsw_rt5645.c
sound/soc/intel/boards/cht_bsw_rt5672.c
sound/soc/intel/boards/sof_es8336.c
sound/soc/intel/boards/sof_wm8804.c

index df3c2a7b64d23c0fdb44c095875a45d3ad17ed6c..8c2b4ab764bbafd0f8a8a8f9ca89f73613a7231f 100644 (file)
@@ -255,7 +255,11 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
                snprintf(codec_name, sizeof(codec_name), "i2c-%s",
                         acpi_dev_name(adev));
                byt_cht_cx2072x_dais[dai_index].codecs->name = codec_name;
+       } else {
+               dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
+               return -ENOENT;
        }
+
        acpi_dev_put(adev);
 
        /* override platform name, if required */
index 08c598b7e1eeeba7eae64264f4baba22a180e511..9178bbe8d9950683c8bed0c2da7f559eea1c6ee2 100644 (file)
@@ -258,7 +258,11 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
                snprintf(codec_name, sizeof(codec_name),
                         "i2c-%s", acpi_dev_name(adev));
                dailink[dai_index].codecs->name = codec_name;
+       } else {
+               dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
+               return -ENOENT;
        }
+
        acpi_dev_put(adev);
 
        /* override platform name, if required */
index 77b91ea4dc32ca3cd65e3e6c21fc4a717dbeb1c4..3539c9ff0fd2ca6ea57a4cf6e4243f2531bba4b8 100644 (file)
@@ -562,7 +562,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
                byt_cht_es8316_dais[dai_index].codecs->name = codec_name;
        } else {
                dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
-               return -ENXIO;
+               return -ENOENT;
        }
 
        codec_dev = acpi_get_first_physical_node(adev);
index db4a33680d9488fa34701555dcc8febfd99cb445..4479825c08b5e3af4d40c359ece3e0c06a715155 100644 (file)
@@ -1693,7 +1693,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
                byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
        } else {
                dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
-               return -ENXIO;
+               return -ENOENT;
        }
 
        codec_dev = acpi_get_first_physical_node(adev);
index 8514b79f389bb53ab9a9385ce712c1eb02b3d70f..1f54da98aacf47c6d0f4a68ad7ea2dfc03ca5dfc 100644 (file)
@@ -926,7 +926,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
                byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name;
        } else {
                dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
-               return -ENXIO;
+               return -ENOENT;
        }
 
        codec_dev = acpi_get_first_physical_node(adev);
index 1da9ceee4d593ea43a08ac62086c9b22deb2165b..ac23a8b7cafca2c4074d159b8f829c17c5401b75 100644 (file)
@@ -582,7 +582,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
                snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
                         "i2c-%s", acpi_dev_name(adev));
                cht_dailink[dai_index].codecs->name = cht_rt5645_codec_name;
+       } else {
+               dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
+               return -ENOENT;
        }
+
        /* acpi_get_first_physical_node() returns a borrowed ref, no need to deref */
        codec_dev = acpi_get_first_physical_node(adev);
        acpi_dev_put(adev);
index d68e5bc755dee52439954db6b0e46af91af2cf9a..c6c469d51243ef189d99dc1d44a637f20aa93cca 100644 (file)
@@ -479,7 +479,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
                snprintf(drv->codec_name, sizeof(drv->codec_name),
                         "i2c-%s", acpi_dev_name(adev));
                cht_dailink[dai_index].codecs->name = drv->codec_name;
+       }  else {
+               dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
+               return -ENOENT;
        }
+
        acpi_dev_put(adev);
 
        /* Use SSP0 on Bay Trail CR devices */
index 2a88efaa6d26bd1d553c4b4919091663e979100a..b45d0501f1090c2b943fc89d33d0a779424a4952 100644 (file)
@@ -681,7 +681,7 @@ static int sof_es8336_probe(struct platform_device *pdev)
                        dai_links[0].codecs->dai_name = "ES8326 HiFi";
        } else {
                dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
-               return -ENXIO;
+               return -ENOENT;
        }
 
        codec_dev = acpi_get_first_physical_node(adev);
index b2d02cc92a6a8dfb22d09ad23a3c1d7c1833a1a7..0a5ce34d7f7bbb705e6cc3bdd5b0764ef0cc7c08 100644 (file)
@@ -270,7 +270,11 @@ static int sof_wm8804_probe(struct platform_device *pdev)
                snprintf(codec_name, sizeof(codec_name),
                         "%s%s", "i2c-", acpi_dev_name(adev));
                dailink[dai_index].codecs->name = codec_name;
+       } else {
+               dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
+               return -ENOENT;
        }
+
        acpi_dev_put(adev);
 
        snd_soc_card_set_drvdata(card, ctx);