LKML Archive mirror
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: Pedro Tammela <pctammela@mojatatu.com>
Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy
Date: Fri, 9 Jun 2023 11:55:50 -0400	[thread overview]
Message-ID: <CAM0EoMm_w5vCfdTTJrPfFCrmWOuqL1_yqCmwHFAZSDdHqVMKZg@mail.gmail.com> (raw)
In-Reply-To: <ce770d0f-20b4-8040-8625-365758351998@mojatatu.com>

On Fri, Jun 9, 2023 at 8:30 AM Pedro Tammela <pctammela@mojatatu.com> wrote:
>
> On 09/06/2023 04:01, Jiapeng Chong wrote:
> > ./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>
>
> LGTM,
>
> Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal

> > ---
> >   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 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;
>

  reply	other threads:[~2023-06-09 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  7:01 [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy Jiapeng Chong
2023-06-09 12:30 ` Pedro Tammela
2023-06-09 15:55   ` Jamal Hadi Salim [this message]
2023-06-12  8:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM0EoMm_w5vCfdTTJrPfFCrmWOuqL1_yqCmwHFAZSDdHqVMKZg@mail.gmail.com \
    --to=jhs@mojatatu.com \
    --cc=abaci@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pctammela@mojatatu.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).