All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
@ 2022-03-17  9:38 Yihao Han
  2022-03-17 13:21 ` Pierre-Louis Bossart
  2022-03-17 19:15 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Yihao Han @ 2022-03-17  9:38 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Ranjani Sridharan,
	Kai Vehmanen, Daniel Baluta, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, sound-open-firmware, alsa-devel, linux-kernel
  Cc: kernel, Yihao Han

fix memdup.cocci warning:
sound/soc/sof/topology.c:876:19-26: WARNING opportunity for kmemdup

Generated by: scripts/coccinelle/api/memdup.cocci

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 sound/soc/sof/topology.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 367fbe2d5b31..369693cc6d10 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -873,11 +873,10 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp,
 
 	/* copy the private data */
 	if (priv_size > 0) {
-		scontrol->priv = kzalloc(priv_size, GFP_KERNEL);
+		scontrol->priv = kmemdup(control->priv.data, priv_size, GFP_KERNEL);
 		if (!scontrol->priv)
 			return -ENOMEM;
 
-		memcpy(scontrol->priv, control->priv.data, priv_size);
 		scontrol->priv_size = priv_size;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
  2022-03-17  9:38 [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy Yihao Han
@ 2022-03-17 13:21 ` Pierre-Louis Bossart
  2022-03-17 19:15 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2022-03-17 13:21 UTC (permalink / raw)
  To: Yihao Han, Liam Girdwood, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	sound-open-firmware, alsa-devel, linux-kernel
  Cc: kernel



On 3/17/22 04:38, Yihao Han wrote:
> fix memdup.cocci warning:
> sound/soc/sof/topology.c:876:19-26: WARNING opportunity for kmemdup
> 
> Generated by: scripts/coccinelle/api/memdup.cocci
> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>

Thanks for the patch

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> ---
>   sound/soc/sof/topology.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index 367fbe2d5b31..369693cc6d10 100644
> --- a/sound/soc/sof/topology.c
> +++ b/sound/soc/sof/topology.c
> @@ -873,11 +873,10 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp,
>   
>   	/* copy the private data */
>   	if (priv_size > 0) {
> -		scontrol->priv = kzalloc(priv_size, GFP_KERNEL);
> +		scontrol->priv = kmemdup(control->priv.data, priv_size, GFP_KERNEL);
>   		if (!scontrol->priv)
>   			return -ENOMEM;
>   
> -		memcpy(scontrol->priv, control->priv.data, priv_size);
>   		scontrol->priv_size = priv_size;
>   	}
>   

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
  2022-03-17  9:38 [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy Yihao Han
  2022-03-17 13:21 ` Pierre-Louis Bossart
@ 2022-03-17 19:15 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-03-17 19:15 UTC (permalink / raw)
  To: Liam Girdwood, Yihao Han, alsa-devel, linux-kernel, Kai Vehmanen,
	Takashi Iwai, sound-open-firmware, Pierre-Louis Bossart,
	Daniel Baluta, Jaroslav Kysela, Ranjani Sridharan
  Cc: kernel

On Thu, 17 Mar 2022 02:38:41 -0700, Yihao Han wrote:
> fix memdup.cocci warning:
> sound/soc/sof/topology.c:876:19-26: WARNING opportunity for kmemdup
> 
> Generated by: scripts/coccinelle/api/memdup.cocci
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
      commit: b26f965f7c83464f60d5af411ef9a03079e41800

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:[~2022-03-17 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17  9:38 [PATCH] ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy Yihao Han
2022-03-17 13:21 ` Pierre-Louis Bossart
2022-03-17 19:15 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.