Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1690263rwd; Fri, 9 Jun 2023 00:15:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uckW/9sXsuCMcKvQnitV3CgMUWVtJUDiNFmsp1PfUYGvAji4UDJH1zcMS4yvCWNiwSX/p X-Received: by 2002:a05:6808:c4:b0:398:bdb:956a with SMTP id t4-20020a05680800c400b003980bdb956amr729829oic.35.1686294932179; Fri, 09 Jun 2023 00:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686294932; cv=none; d=google.com; s=arc-20160816; b=0ywZw83mNj9O9QAn0tKKLAntQcvhwBFtno2bgFzX/0eoYXLDI5nS8MTqY55XkrUKY5 CbhVT439AlWC2v64mOp84bMeTLA+vVJLR9XLMl3M+hggWgLlPjwGlwVj+jauBhIDFiYP VMBPTlZh6I0TdBUPZAeccDjAvHuXjBgGlMjZBJ+kXCW+14KukzGguRC+trExiI8o1SQi nHMX2Y7pRBvz4a59Q6/FsMjMg9sNmFQ56NbdXy2vV3asnA4WybiBmUwKVHNJ4IX95rLC a6nYXL4NGohJs1neXU96t6h7/j/fOQb6w+kyau2XuWcc+zQ2vYf3Tjhm2oOAxPKnivKf TG+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QlUmZ8vVks77k5OLOkd44AYaUcskr/V9sMJ1mb2RXzo=; b=QC8mJK7zrYB2Inzf7sMwpZ8wFWXhGJ6Oq5llVa5GV5EfgFFsinO8uYp7bOlruJE0sy nlsU/hodHNxlwNHGziwND/UHh57EsE+g0ECTxh0O3DpIA/kTha5R/yPWhUIfOHgclX3z jV3msRjkn2Af83yOdr6/0az3g9VS/gt0aU8Vt6i87geC0fhq9tvE0OrKtxOUbGhzsB3+ MbhlItpHGZdpeFvLq+15P4cWI1d1dc5UdoXLhFU6oHG6OqAQGq+BtqrNTcCRwv0hHt+i 0ey4PQ27KKuZoTnk0GBCHa/5cKaGWiOGdX8ZQEbmGfxIRVBxjcu0nB5jAEkwDcj0ZWth rVyQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu5-20020a17090b388500b0025678db4f6fsi2446253pjb.76.2023.06.09.00.15.17; Fri, 09 Jun 2023 00:15:32 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237988AbjFIHBs (ORCPT + 99 others); Fri, 9 Jun 2023 03:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237823AbjFIHBh (ORCPT ); Fri, 9 Jun 2023 03:01:37 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E5B26AD; Fri, 9 Jun 2023 00:01:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R851e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Vkh.u4r_1686294078; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0Vkh.u4r_1686294078) by smtp.aliyun-inc.com; Fri, 09 Jun 2023 15:01:27 +0800 From: Jiapeng Chong To: 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, Jiapeng Chong , Abaci Robot Subject: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc + memcpy Date: Fri, 9 Jun 2023 15:01:17 +0800 Message-Id: <20230609070117.100507-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_IN_DEF_SPF_WL 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 ./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 --- 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; -- 2.20.1.7.g153144c