diff options
author | Jiapeng Chong <jiapeng.chong@linux.alibaba.com> | 2023-06-09 15:01:17 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-06-12 09:31:09 +0100 |
commit | 26e35370b9766914364409626035fda2c63fef05 (patch) | |
tree | 90521d0cc012a41cf762131b838aa29763a451aa /net/sched | |
parent | 132b4ebfa090492663f84144a1e7afaca54cd58a (diff) | |
download | linux-stable-26e35370b9766914364409626035fda2c63fef05.tar.gz linux-stable-26e35370b9766914364409626035fda2c63fef05.tar.bz2 linux-stable-26e35370b9766914364409626035fda2c63fef05.zip |
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 <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5478
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/act_pedit.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index fc945c7e4123..8c4e7fddddbf 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; |