* [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value
@ 2024-09-25 8:00 Charles Han
2024-09-25 8:46 ` Pierre-Louis Bossart
2024-10-02 17:37 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Charles Han @ 2024-09-25 8:00 UTC (permalink / raw)
To: yung-chuan.liao, ckeepax
Cc: alsa-devel, pierre-louis.bossart, liam.r.girdwood, peter.ujfalusi,
broonie, tiwai, linux-sound, linux-kernel, Charles Han
devm_kasprintf() can return a NULL pointer on failure but this
returned value is not checked.
Fixes: b359760d95ee ("ASoC: intel: sof_sdw: Add simple DAI link creation helper")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
sound/soc/intel/boards/sof_sdw.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index d258728d64cf..26917f6f15cf 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -919,6 +919,9 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", i);
char *codec_name = devm_kasprintf(dev, GFP_KERNEL, "i2c-%s:0%d",
ssp_info->acpi_id, j++);
+ if (!name || !cpu_dai_name || !codec_name)
+ return -ENOMEM;
+
int playback = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
int capture = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];
@@ -985,6 +988,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
for (i = 0; i < hdmi_num; i++) {
char *name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1);
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1);
+ if (!name || !cpu_dai_name)
+ return -ENOMEM;
+
char *codec_name, *codec_dai_name;
if (intel_ctx->hdmi.idisp_codec) {
@@ -996,6 +1002,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
codec_dai_name = "snd-soc-dummy-dai";
}
+ if (!codec_dai_name)
+ return -ENOMEM;
+
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1, 0, // HDMI only supports playback
cpu_dai_name, platform_component->name,
@@ -1019,6 +1028,9 @@ static int create_bt_dailinks(struct snd_soc_card *card,
SOF_BT_OFFLOAD_SSP_SHIFT;
char *name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
+ if (!name || !cpu_dai_name)
+ return -ENOMEM;
+
int ret;
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value
2024-09-25 8:00 [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value Charles Han
@ 2024-09-25 8:46 ` Pierre-Louis Bossart
2024-10-02 17:37 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2024-09-25 8:46 UTC (permalink / raw)
To: Charles Han, yung-chuan.liao, ckeepax
Cc: alsa-devel, liam.r.girdwood, peter.ujfalusi, broonie, tiwai,
linux-sound, linux-kernel
On 9/25/24 10:00, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure but this
> returned value is not checked.
>
> Fixes: b359760d95ee ("ASoC: intel: sof_sdw: Add simple DAI link creation helper")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
> sound/soc/intel/boards/sof_sdw.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
> index d258728d64cf..26917f6f15cf 100644
> --- a/sound/soc/intel/boards/sof_sdw.c
> +++ b/sound/soc/intel/boards/sof_sdw.c
> @@ -919,6 +919,9 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
> char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", i);
> char *codec_name = devm_kasprintf(dev, GFP_KERNEL, "i2c-%s:0%d",
> ssp_info->acpi_id, j++);
> + if (!name || !cpu_dai_name || !codec_name)
> + return -ENOMEM;
> +
all 3 changes are correct, thanks for the patch. The only nit-pick is
that I would have moved the devm_ allocation + test lower to be
consistent with the coding style which avoids mixing code and declarations.
> int playback = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
> int capture = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];
>
> @@ -985,6 +988,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
> for (i = 0; i < hdmi_num; i++) {
> char *name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1);
> char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1);
> + if (!name || !cpu_dai_name)
> + return -ENOMEM;
> +
> char *codec_name, *codec_dai_name;
>
> if (intel_ctx->hdmi.idisp_codec) {
> @@ -996,6 +1002,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
> codec_dai_name = "snd-soc-dummy-dai";
> }
>
> + if (!codec_dai_name)
> + return -ENOMEM;
> +
> ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
> 1, 0, // HDMI only supports playback
> cpu_dai_name, platform_component->name,
> @@ -1019,6 +1028,9 @@ static int create_bt_dailinks(struct snd_soc_card *card,
> SOF_BT_OFFLOAD_SSP_SHIFT;
> char *name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
> char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
> + if (!name || !cpu_dai_name)
> + return -ENOMEM;
> +
> int ret;
>
> ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value
2024-09-25 8:00 [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value Charles Han
2024-09-25 8:46 ` Pierre-Louis Bossart
@ 2024-10-02 17:37 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-10-02 17:37 UTC (permalink / raw)
To: yung-chuan.liao, ckeepax, Charles Han
Cc: alsa-devel, liam.r.girdwood, peter.ujfalusi, tiwai, linux-sound,
linux-kernel, Pierre-Louis Bossart
On Wed, 25 Sep 2024 16:00:30 +0800, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure but this
> returned value is not checked.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value
commit: 2c0b2b484b164072ba6cf52af1bde85158fc75d4
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-02 17:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 8:00 [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value Charles Han
2024-09-25 8:46 ` Pierre-Louis Bossart
2024-10-02 17:37 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox