lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <814913ab-903a-4395-bfb9-5fcbb9d3a5f2@linux.intel.com>
Date: Wed, 25 Sep 2024 10:46:08 +0200
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
To: Charles Han <hanchunchao@...pur.com>, yung-chuan.liao@...ux.intel.com,
 ckeepax@...nsource.cirrus.com
Cc: alsa-devel@...a-project.org, liam.r.girdwood@...ux.intel.com,
 peter.ujfalusi@...ux.intel.com, broonie@...nel.org, tiwai@...e.com,
 linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ASoC: intel: sof_sdw: Add check devm_kasprintf() returned
 value



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@...pur.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,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ