diff options
author | Yihao Han <hanyihao@vivo.com> | 2021-12-06 22:44:18 -0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-12-07 21:49:05 -0800 |
commit | e44aecc709ad3945e152c120693127d468e6487c (patch) | |
tree | 82cd85127b811bc7b1923531f5a397d83f265a92 | |
parent | d418f67e987fe8c8b2d34caf98ac0fb9f08c5dd5 (diff) |
net: dsa: felix: use kmemdup() to replace kmalloc + memcpy
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>
Link: https://lore.kernel.org/r/20211207064419.38632-1-hanyihao@vivo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/dsa/ocelot/felix_vsc9959.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 74c5c8cd664a..110d6c403bdd 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1505,12 +1505,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) { @@ -1626,11 +1624,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); |