linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy
@ 2021-12-07  6:44 Yihao Han
  2021-12-07 13:56 ` Vladimir Oltean
  2021-12-08  6:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yihao Han @ 2021-12-07  6:44 UTC (permalink / raw)
  To: Vladimir Oltean, Claudiu Manoil, Alexandre Belloni,
	UNGLinuxDriver, Andrew Lunn, Vivien Didelot, Florian Fainelli,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel
  Cc: kernel, Yihao Han

Fix following coccicheck warning:
/drivers/net/dsa/ocelot/felix_vsc9959.c:1627:13-20:
WARNING opportunity for kmemdup
/drivers/net/dsa/ocelot/felix_vsc9959.c:1506:16-23:
WARNING opportunity for kmemdup

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 drivers/net/dsa/ocelot/felix_vsc9959.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 9add86eda7e3..0076420308a7 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -1503,12 +1503,10 @@ static int vsc9959_stream_table_add(struct ocelot *ocelot,
 	struct felix_stream *stream_entry;
 	int ret;
 
-	stream_entry = kzalloc(sizeof(*stream_entry), GFP_KERNEL);
+	stream_entry = kmemdup(stream, sizeof(*stream_entry), GFP_KERNEL);
 	if (!stream_entry)
 		return -ENOMEM;
 
-	memcpy(stream_entry, stream, sizeof(*stream_entry));
-
 	if (!stream->dummy) {
 		ret = vsc9959_mact_stream_set(ocelot, stream_entry, extack);
 		if (ret) {
@@ -1624,11 +1622,10 @@ static int vsc9959_psfp_sfi_list_add(struct ocelot *ocelot,
 	struct felix_stream_filter *sfi_entry;
 	int ret;
 
-	sfi_entry = kzalloc(sizeof(*sfi_entry), GFP_KERNEL);
+	sfi_entry = kmemdup(sfi, sizeof(*sfi_entry), GFP_KERNEL);
 	if (!sfi_entry)
 		return -ENOMEM;
 
-	memcpy(sfi_entry, sfi, sizeof(*sfi_entry));
 	refcount_set(&sfi_entry->refcount, 1);
 
 	ret = vsc9959_psfp_sfi_set(ocelot, sfi_entry);
-- 
2.17.1


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

* Re: [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy
  2021-12-07  6:44 [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy Yihao Han
@ 2021-12-07 13:56 ` Vladimir Oltean
  2021-12-08  6:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2021-12-07 13:56 UTC (permalink / raw)
  To: Yihao Han
  Cc: Claudiu Manoil, Alexandre Belloni, UNGLinuxDriver, Andrew Lunn,
	Vivien Didelot, Florian Fainelli, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel, kernel

On Mon, Dec 06, 2021 at 10:44:18PM -0800, Yihao Han wrote:
> Fix following coccicheck warning:
> /drivers/net/dsa/ocelot/felix_vsc9959.c:1627:13-20:
> WARNING opportunity for kmemdup
> /drivers/net/dsa/ocelot/felix_vsc9959.c:1506:16-23:
> WARNING opportunity for kmemdup
> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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

* Re: [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy
  2021-12-07  6:44 [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy Yihao Han
  2021-12-07 13:56 ` Vladimir Oltean
@ 2021-12-08  6:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-08  6:10 UTC (permalink / raw)
  To: Yihao Han
  Cc: vladimir.oltean, claudiu.manoil, alexandre.belloni,
	UNGLinuxDriver, andrew, vivien.didelot, f.fainelli, davem, kuba,
	netdev, linux-kernel, kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  6 Dec 2021 22:44:18 -0800 you wrote:
> Fix following coccicheck warning:
> /drivers/net/dsa/ocelot/felix_vsc9959.c:1627:13-20:
> WARNING opportunity for kmemdup
> /drivers/net/dsa/ocelot/felix_vsc9959.c:1506:16-23:
> WARNING opportunity for kmemdup
> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> 
> [...]

Here is the summary with links:
  - net: dsa: felix: use kmemdup() to replace kmalloc + memcpy
    https://git.kernel.org/netdev/net-next/c/e44aecc709ad

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-12-08  6:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07  6:44 [PATCH] net: dsa: felix: use kmemdup() to replace kmalloc + memcpy Yihao Han
2021-12-07 13:56 ` Vladimir Oltean
2021-12-08  6:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).