Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2336567rwd; Fri, 9 Jun 2023 09:40:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZJYjkRo5qYoDsFJa8sH1BpZmIJK3+Fw5NIWk9lYMGckvQKPU9I2nvv18/FHQN72jv2NjI X-Received: by 2002:a17:90a:f0c3:b0:253:8e59:a867 with SMTP id fa3-20020a17090af0c300b002538e59a867mr1594096pjb.42.1686328831510; Fri, 09 Jun 2023 09:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686328831; cv=none; d=google.com; s=arc-20160816; b=vCtbjwVvgkNg/jG0ZpZ7eMD45UNqBM1WmRJOATf5DUQhLsrF0JBqoP97O16EMLJy0l EBCB0pg3eO5bYPoiFUzy4dkLB0g5fg1DiZNrZXk/Ma05Gfgg5dmsb7VaUCteHmO954Xz Z2rulKb6WUBmm+tsWx9rLwb9fPi4kC/BO5MX3sgOCvhiIGXWkHH0UQ1xM4+g82/npnNr FFvM+gUdnh0kLu7OGY0CB788h4UAN3C8N2oKZmcQv/GvhjC++M7uRJZ2iuP82YqiKdM2 q+MKJKSGsWPKT/OEW65/djtheQ9rc2ehFmDtJu4td6XTkdtfJcXUc/tXdgKgIMK2IGCH 9Zdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=hjQ4waiFgY2SpS6vfX+NQ6H8ClBpY8gsNtdTsuAeGow=; b=RpVIBh4yXNdLG+yRR5sX7zyMvXzfHaZTbwJR1dO7CL46HXyTl+V8Ya6xwkVhpaoj8k 3GIyP3Ssl41yYvw8J0HGky5e2wQWTdI3Sr220W9TKUHCN72OdD3JuX8/EHWiOYCyOUme QpKaJb92/6kKW0fffhDi8RivpaO5Fbhk3inNVUD45ig7FoGymGuto10JsA1RnsztJFqh NK5pBoAXPibpRQ01qMB4ZdsyO9KV3w8kuyIgyXdALi92ohD/TuosAUx98/+1CE3ssxK4 ms+XFy+vmywrsOecr2l7cTcDsJGiMhvHZZGQmpa77CafWtiwFeU6oJ6eAfNi8rU5BfuU 5Iaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=Hahr+2kw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw1-20020a17090b180100b002568322e3d0si3096458pjb.34.2023.06.09.09.40.19; Fri, 09 Jun 2023 09:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=Hahr+2kw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241909AbjFIP4J (ORCPT + 99 others); Fri, 9 Jun 2023 11:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238095AbjFIP4H (ORCPT ); Fri, 9 Jun 2023 11:56:07 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9B2359A for ; Fri, 9 Jun 2023 08:56:03 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-bab8f66d3a2so1834837276.3 for ; Fri, 09 Jun 2023 08:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1686326163; x=1688918163; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hjQ4waiFgY2SpS6vfX+NQ6H8ClBpY8gsNtdTsuAeGow=; b=Hahr+2kwlcgcYlWWa13W2s5PfYpu9RxRktd/OckDlJw9u8XVx/J/BE4+y95GCyz6ZI CgBOCMtmD/sEHGjXj0z40ZX07nkj9iPEx3IbqIFVqftn5dkB2ym/CYLNzNK/Fzuc0qu4 QV0Qlwkl48D/y5ECYJInJZLAmAe3k23hcW6yyfs4bUnhvcjhEj+u4Bnrbvx4SEIYKKO9 DBpFjQHUWGvecCRtzMk6kQmubkvsTni8r1HSyx3s1dDurs7O4Eo/72xYMtlTmC7sYTGq Rg+cJi0Wwoz8fo1cYBw6G4G30t7XIuQ8ZpAyXH07Tuno6pfThfSeoh1q53y8IynYj2AW Z/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686326163; x=1688918163; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hjQ4waiFgY2SpS6vfX+NQ6H8ClBpY8gsNtdTsuAeGow=; b=XfumGdhxa9N2HHBHE6yIWnzxUaRyVfoQhMes3wbPqbrH9RN49Vzn200wAN6MzuhiTD nTIB21JJXw0D/80rMHrk0hndGSA1fVLW+ulCE7n8+7+s/T+xMn7KZT0wWIkkAPqsGYhT U4xA0VKppX7vdnuNjcWuKojO5QKSmj4FlqD/irzgf8PURSK+946CC9dJiON/a9teT7ud ISHSQVzdu0OxfdhClVmMhxhvo2326hCDA+2pfjVkDw/dGWelhiacrYtxb8D5sMl92anO dmSlDLDklIS7xp7t+sEM8GClUe8oy1dG5IJmgpI2iCI3g8yqrMFn1v4huI1DRAjpfHgi JvUg== X-Gm-Message-State: AC+VfDwxodfgelc2jwJDpMwfnIBjrxMyjKD5GzPVIUhJDr7yFmVq63z5 Epy1KwcwZc8i2G9LOhtorxH0lvSefGmlwz6IxZdlIg== X-Received: by 2002:a0d:cf86:0:b0:565:2328:1db5 with SMTP id r128-20020a0dcf86000000b0056523281db5mr1284744ywd.48.1686326162595; Fri, 09 Jun 2023 08:56:02 -0700 (PDT) MIME-Version: 1.0 References: <20230609070117.100507-1-jiapeng.chong@linux.alibaba.com> In-Reply-To: From: Jamal Hadi Salim Date: Fri, 9 Jun 2023 11:55:50 -0400 Message-ID: Subject: Re: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy To: Pedro Tammela Cc: Jiapeng Chong , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 9, 2023 at 8:30=E2=80=AFAM Pedro Tammela 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 > > Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=3D5478 > > Signed-off-by: Jiapeng Chong > > LGTM, > > Reviewed-by: Pedro Tammela Acked-by: Jamal Hadi Salim 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 =3D parm->flags; > > nparms->tcfp_nkeys =3D parm->nkeys; > > > > - nparms->tcfp_keys =3D kmalloc(ksize, GFP_KERNEL); > > + nparms->tcfp_keys =3D kmemdup(parm->keys, ksize, GFP_KERNEL); > > if (!nparms->tcfp_keys) { > > ret =3D -ENOMEM; > > goto put_chain; > > } > > > > - memcpy(nparms->tcfp_keys, parm->keys, ksize); > > - > > for (i =3D 0; i < nparms->tcfp_nkeys; ++i) { > > u32 offmask =3D nparms->tcfp_keys[i].offmask; > > u32 cur =3D nparms->tcfp_keys[i].off; >