All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] sound: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-08  8:36 ` zhong jiang
  0 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

I find the issue with the help of Coccinelle.

zhong jiang (2):
  sound: q6core: Use kmemdup to replace kzalloc + memcpy
  sound: skl-topology: Use kmemdup to replace kzalloc + memcpy

 sound/soc/intel/skylake/skl-topology.c | 3 +--
 sound/soc/qcom/qdsp6/q6core.c          | 8 ++------
 2 files changed, 3 insertions(+), 8 deletions(-)

-- 
1.7.12.4


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

* [PATCH 0/2] sound: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-08  8:36 ` zhong jiang
  0 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

I find the issue with the help of Coccinelle.

zhong jiang (2):
  sound: q6core: Use kmemdup to replace kzalloc + memcpy
  sound: skl-topology: Use kmemdup to replace kzalloc + memcpy

 sound/soc/intel/skylake/skl-topology.c | 3 +--
 sound/soc/qcom/qdsp6/q6core.c          | 8 ++------
 2 files changed, 3 insertions(+), 8 deletions(-)

-- 
1.7.12.4

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

* [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
  2018-09-08  8:36 ` zhong jiang
@ 2018-09-08  8:36   ` zhong jiang
  -1 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to use the kmemdup rather than the open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 sound/soc/qcom/qdsp6/q6core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c
index 06f03a5..ca1be73 100644
--- a/sound/soc/qcom/qdsp6/q6core.c
+++ b/sound/soc/qcom/qdsp6/q6core.c
@@ -105,12 +105,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
 		bytes = sizeof(*fwk) + fwk->num_services *
 				sizeof(fwk->svc_api_info[0]);
 
-		core->fwk_version = kzalloc(bytes, GFP_ATOMIC);
+		core->fwk_version = kmemdup(data->payload, bytes, GFP_ATOMIC);
 		if (!core->fwk_version)
 			return -ENOMEM;
 
-		memcpy(core->fwk_version, data->payload, bytes);
-
 		core->fwk_version_supported = true;
 		core->resp_received = true;
 
@@ -124,12 +122,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
 
 		len = sizeof(*v) + v->num_services * sizeof(v->svc_api_info[0]);
 
-		core->svc_version = kzalloc(len, GFP_ATOMIC);
+		core->svc_version = kmemdup(data->payload, len, GFP_ATOMIC);
 		if (!core->svc_version)
 			return -ENOMEM;
 
-		memcpy(core->svc_version, data->payload, len);
-
 		core->get_version_supported = true;
 		core->resp_received = true;
 
-- 
1.7.12.4


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

* [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-08  8:36   ` zhong jiang
  0 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to use the kmemdup rather than the open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 sound/soc/qcom/qdsp6/q6core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c
index 06f03a5..ca1be73 100644
--- a/sound/soc/qcom/qdsp6/q6core.c
+++ b/sound/soc/qcom/qdsp6/q6core.c
@@ -105,12 +105,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
 		bytes = sizeof(*fwk) + fwk->num_services *
 				sizeof(fwk->svc_api_info[0]);
 
-		core->fwk_version = kzalloc(bytes, GFP_ATOMIC);
+		core->fwk_version = kmemdup(data->payload, bytes, GFP_ATOMIC);
 		if (!core->fwk_version)
 			return -ENOMEM;
 
-		memcpy(core->fwk_version, data->payload, bytes);
-
 		core->fwk_version_supported = true;
 		core->resp_received = true;
 
@@ -124,12 +122,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
 
 		len = sizeof(*v) + v->num_services * sizeof(v->svc_api_info[0]);
 
-		core->svc_version = kzalloc(len, GFP_ATOMIC);
+		core->svc_version = kmemdup(data->payload, len, GFP_ATOMIC);
 		if (!core->svc_version)
 			return -ENOMEM;
 
-		memcpy(core->svc_version, data->payload, len);
-
 		core->get_version_supported = true;
 		core->resp_received = true;
 
-- 
1.7.12.4

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

* [PATCH 2/2] sound: skl-topology: Use kmemdup to replace kzalloc + memcpy
  2018-09-08  8:36 ` zhong jiang
@ 2018-09-08  8:36   ` zhong jiang
  -1 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to kmemdup rather than the open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 sound/soc/intel/skylake/skl-topology.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 2620d77..52a9915 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -898,11 +898,10 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
 			bc = (struct skl_algo_data *)sb->dobj.private;
 
 			if (bc->set_params == SKL_PARAM_BIND) {
-				params = kzalloc(bc->max, GFP_KERNEL);
+				params = kmemdup(bc->params, bc->max, GFP_KERNEL);
 				if (!params)
 					return -ENOMEM;
 
-				memcpy(params, bc->params, bc->max);
 				skl_fill_sink_instance_id(ctx, params, bc->max,
 								mconfig);
 
-- 
1.7.12.4


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

* [PATCH 2/2] sound: skl-topology: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-08  8:36   ` zhong jiang
  0 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-08  8:36 UTC (permalink / raw)
  To: tiwai, perex, broonie; +Cc: lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to kmemdup rather than the open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 sound/soc/intel/skylake/skl-topology.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 2620d77..52a9915 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -898,11 +898,10 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
 			bc = (struct skl_algo_data *)sb->dobj.private;
 
 			if (bc->set_params == SKL_PARAM_BIND) {
-				params = kzalloc(bc->max, GFP_KERNEL);
+				params = kmemdup(bc->params, bc->max, GFP_KERNEL);
 				if (!params)
 					return -ENOMEM;
 
-				memcpy(params, bc->params, bc->max);
 				skl_fill_sink_instance_id(ctx, params, bc->max,
 								mconfig);
 
-- 
1.7.12.4

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

* Re: [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
  2018-09-08  8:36   ` zhong jiang
@ 2018-09-10 14:19     ` Mark Brown
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2018-09-10 14:19 UTC (permalink / raw)
  To: zhong jiang
  Cc: tiwai, perex, lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

On Sat, Sep 08, 2018 at 04:36:19PM +0800, zhong jiang wrote:
> kmemdup has implemented the function that kzalloc() + memcpy() will
> do. and we prefer to use the kmemdup rather than the open coded implementation.

Please submit patches using subject lines reflecting the style for the
subsystem.  This makes it easier for people to identify relevant
patches.  Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-10 14:19     ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2018-09-10 14:19 UTC (permalink / raw)
  To: zhong jiang; +Cc: alsa-devel, bgoswami, linux-kernel, plai, lgirdwood, tiwai


[-- Attachment #1.1: Type: text/plain, Size: 499 bytes --]

On Sat, Sep 08, 2018 at 04:36:19PM +0800, zhong jiang wrote:
> kmemdup has implemented the function that kzalloc() + memcpy() will
> do. and we prefer to use the kmemdup rather than the open coded implementation.

Please submit patches using subject lines reflecting the style for the
subsystem.  This makes it easier for people to identify relevant
patches.  Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
  2018-09-10 14:19     ` Mark Brown
@ 2018-09-11  1:13       ` zhong jiang
  -1 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-11  1:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: tiwai, perex, lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

On 2018/9/10 22:19, Mark Brown wrote:
> On Sat, Sep 08, 2018 at 04:36:19PM +0800, zhong jiang wrote:
>> kmemdup has implemented the function that kzalloc() + memcpy() will
>> do. and we prefer to use the kmemdup rather than the open coded implementation.
> Please submit patches using subject lines reflecting the style for the
> subsystem.  This makes it easier for people to identify relevant
> patches.  Look at what existing commits in the area you're changing are
> doing and make sure your subject lines visually resemble what they're
> doing.
I will notice this next time.  Thanks

Sincerely,
zhong jiang


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

* Re: [PATCH 1/2] sound: q6core: Use kmemdup to replace kzalloc + memcpy
@ 2018-09-11  1:13       ` zhong jiang
  0 siblings, 0 replies; 10+ messages in thread
From: zhong jiang @ 2018-09-11  1:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: tiwai, perex, lgirdwood, bgoswami, plai, alsa-devel, linux-kernel

On 2018/9/10 22:19, Mark Brown wrote:
> On Sat, Sep 08, 2018 at 04:36:19PM +0800, zhong jiang wrote:
>> kmemdup has implemented the function that kzalloc() + memcpy() will
>> do. and we prefer to use the kmemdup rather than the open coded implementation.
> Please submit patches using subject lines reflecting the style for the
> subsystem.  This makes it easier for people to identify relevant
> patches.  Look at what existing commits in the area you're changing are
> doing and make sure your subject lines visually resemble what they're
> doing.
I will notice this next time.  Thanks

Sincerely,
zhong jiang

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

end of thread, other threads:[~2018-09-11  1:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-08  8:36 [PATCH 0/2] sound: Use kmemdup to replace kzalloc + memcpy zhong jiang
2018-09-08  8:36 ` zhong jiang
2018-09-08  8:36 ` [PATCH 1/2] sound: q6core: " zhong jiang
2018-09-08  8:36   ` zhong jiang
2018-09-10 14:19   ` Mark Brown
2018-09-10 14:19     ` Mark Brown
2018-09-11  1:13     ` zhong jiang
2018-09-11  1:13       ` zhong jiang
2018-09-08  8:36 ` [PATCH 2/2] sound: skl-topology: " zhong jiang
2018-09-08  8:36   ` zhong jiang

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.