Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2010060rwd; Fri, 9 Jun 2023 05:35:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ713oppiW2iAsRREbMUcUblik005Yf2J/lHKaVZApMHvgDyKRDWQi1Ia6HGJG2iw6TTdQ1n X-Received: by 2002:a17:903:11c6:b0:1b3:696f:b83 with SMTP id q6-20020a17090311c600b001b3696f0b83mr759010plh.45.1686314102505; Fri, 09 Jun 2023 05:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686314102; cv=none; d=google.com; s=arc-20160816; b=fBiyrZCCdwCjwtNqpOhEPEQiqNwB2aBCDf2v5rhrSQKkolwCk3Ytm0raTYPJHLtOaB m2idzAw0q4puNaNJkHPkQ3HDJGpdqJ2+9PZKgF8iEV8b8qMcRmwO827e+X1SG5thmdHB NLsEbYbtG3Hs+DZMLrB8b2kMCNxJSaSjJGA96SOjE85IR0vSg1lGYtXOZ0MckOJys7VY g6fBSAtYIs68EC0/Il6mg9r3ygiyjmbum2u3JSmS+ZrJSAeYnJirtUVXs8h7rhcSkVB1 X6Tx2CHEAViap8qJG5sfrlcXCkYXISnnKi8zynp+szfVzYXwSm4Zwdi/vHCfjhY0pktF t3eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OhY9F426/XZBDfWDG79w1KFjKHgE+TlbQzvvhGcm+pE=; b=F/ucNnFsiQRtSMwg9IecyKLzMfI4Tk+hI+XAnp705jYoifrDdj8/l9n2PGSVNkFFEL Mg7QpMF9fAKjmnaS9gT6OLqFgLNfiv+IH+jaoMZDDjTtjXKn0BoXt72ugZ578OKMxHs7 /6qwo8cgCzer46PcYs5Hy9cVYw7wC785udkpe8c+mz9oMeagZbJHLWlKM6QDUqNbAgVp zpS7nUBLwP7EODKRaqRbz+AWvmbMJ1VT9+wyw+qN6wArV+1IoMaFt1MvAcbP+Y/7IPIz 8204MCWlk3tUeToigZUivDm6IQICFl/Vh7t2Hft+YcniDMhxZ18Ko0nRfYqVY23mZTgG rT2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=26w7TL8p; 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 w10-20020a170902c78a00b001ab1d1a6802si2592768pla.1.2023.06.09.05.34.49; Fri, 09 Jun 2023 05:35:02 -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=26w7TL8p; 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 S236150AbjFIMbE (ORCPT + 99 others); Fri, 9 Jun 2023 08:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbjFIMbD (ORCPT ); Fri, 9 Jun 2023 08:31:03 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D260F3AA1 for ; Fri, 9 Jun 2023 05:30:25 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-19f31d6b661so663471fac.0 for ; Fri, 09 Jun 2023 05:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1686313816; x=1688905816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=OhY9F426/XZBDfWDG79w1KFjKHgE+TlbQzvvhGcm+pE=; b=26w7TL8p4QsaCxqNELPKZl0nf/3DIA4tnu5Z8yBaaMHQs6nJdtoL1/IJwGh8Xnqrul ceyIop0m88PtIMieJZNuYYbD/f2aPr+QAgKlDI4QCHaqKwiuAJdXHnqdd/Y4WTeV0kFF +cy/Kl06Bx5/Zyi6ieZfFwUmWxzKs65SzA7ozL6+ye7vj6isA71BUY2ZZFcRKUgRZodv RI2o0K3tz9AhHI4WOGQfYmNOTK61fDf27e3WzQtyXXB2KJrclrxX2QPz5GKoP1ag2Isg Tu+rwCSeuKR7iKJdPxkioShwiSXaONWzCieOz4ysJSPBOlZBj3CblganCvCX44cWRMdj aV/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686313816; x=1688905816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OhY9F426/XZBDfWDG79w1KFjKHgE+TlbQzvvhGcm+pE=; b=Ko7D7bZv5nedGiv32JWHjuv+a1/MOV4Ru/hMrrdSUhtU0aTRYm/e0oFNNW/gHXQIed sOPrkNrYxiXGLspjSjW9QCZzHqc7ZkcJphHXoqkLAuf+i3KtGqD0WGheBpPTDtUl8BW8 tPpHKtGazBOduHOrojGsWBZA8RXQlRi9ZAayp0QAF3ce3THQhI4SyfEs1hqAb33ocARv RH3N2JxElY4wnlBYvNKgolVx2kJ0kjWe3Sg/gvEQBV45I1gnm+5xUbVWMy54GVCcdseQ sQW3g3EvxAYEtxggYQwoWuUbuPXCFkXt5CqtiGeWhKqlbgLOCzW0aZZGww/1U+5nGkBT VHLA== X-Gm-Message-State: AC+VfDzyCl2uaswoVxDqhGGXWdmdaXkBdgeaEzUWI4gC+pGoR3W0meDm aqeIHn3LgBkW2dxmGkim1d2yyA== X-Received: by 2002:a05:6870:e282:b0:19f:5c37:ab9d with SMTP id v2-20020a056870e28200b0019f5c37ab9dmr1164399oad.43.1686313816386; Fri, 09 Jun 2023 05:30:16 -0700 (PDT) Received: from ?IPV6:2804:14d:5c5e:44fb:643a:b27d:4a69:3b94? ([2804:14d:5c5e:44fb:643a:b27d:4a69:3b94]) by smtp.gmail.com with ESMTPSA id p14-20020a056870a54e00b0017b21991355sm2052528oal.20.2023.06.09.05.30.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 05:30:16 -0700 (PDT) Message-ID: Date: Fri, 9 Jun 2023 09:30:11 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy Content-Language: en-US To: Jiapeng Chong , jhs@mojatatu.com Cc: 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 References: <20230609070117.100507-1-jiapeng.chong@linux.alibaba.com> From: Pedro Tammela In-Reply-To: <20230609070117.100507-1-jiapeng.chong@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 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=5478 > Signed-off-by: Jiapeng Chong LGTM, Reviewed-by: Pedro Tammela > --- > 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;