From 26e35370b9766914364409626035fda2c63fef05 Mon Sep 17 00:00:00 2001 From: Jiapeng Chong Date: Fri, 9 Jun 2023 15:01:17 +0800 Subject: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy ./net/sched/act_pedit.c:245:21-28: WARNING opportunity for kmemdup. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5478 Signed-off-by: Jiapeng Chong Reviewed-by: Pedro Tammela Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller --- net/sched/act_pedit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index fc945c7..8c4e7fd 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -242,14 +242,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, nparms->tcfp_flags = parm->flags; nparms->tcfp_nkeys = parm->nkeys; - nparms->tcfp_keys = kmalloc(ksize, GFP_KERNEL); + nparms->tcfp_keys = kmemdup(parm->keys, ksize, GFP_KERNEL); if (!nparms->tcfp_keys) { ret = -ENOMEM; goto put_chain; } - memcpy(nparms->tcfp_keys, parm->keys, ksize); - for (i = 0; i < nparms->tcfp_nkeys; ++i) { u32 offmask = nparms->tcfp_keys[i].offmask; u32 cur = nparms->tcfp_keys[i].off; -- 2.7.4