Commit 26e35370 authored by Jiapeng Chong's avatar Jiapeng Chong Committed by David S. Miller

net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy

./net/sched/act_pedit.c:245:21-28: WARNING opportunity for kmemdup.
Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5478Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 132b4ebf
...@@ -242,14 +242,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, ...@@ -242,14 +242,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
nparms->tcfp_flags = parm->flags; nparms->tcfp_flags = parm->flags;
nparms->tcfp_nkeys = parm->nkeys; 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) { if (!nparms->tcfp_keys) {
ret = -ENOMEM; ret = -ENOMEM;
goto put_chain; goto put_chain;
} }
memcpy(nparms->tcfp_keys, parm->keys, ksize);
for (i = 0; i < nparms->tcfp_nkeys; ++i) { for (i = 0; i < nparms->tcfp_nkeys; ++i) {
u32 offmask = nparms->tcfp_keys[i].offmask; u32 offmask = nparms->tcfp_keys[i].offmask;
u32 cur = nparms->tcfp_keys[i].off; u32 cur = nparms->tcfp_keys[i].off;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment