Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1527562rwn; Thu, 8 Sep 2022 22:56:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR48PF8mcyaS/E+Do4lSJG+5rLRx/U9r4kVsVofSuOZ0+WtSnS1FfBip2+fe9yfEm8Eymk8T X-Received: by 2002:a05:651c:33a:b0:26a:a0de:d6e3 with SMTP id b26-20020a05651c033a00b0026aa0ded6e3mr3492045ljp.397.1662702965888; Thu, 08 Sep 2022 22:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662702965; cv=none; d=google.com; s=arc-20160816; b=wLbxDO8CghYzW7qIR+X0SKnbIH6OpkJOGDm63dGvxQgjCJ59ToKzYwIxPnL/OC80fE CR0iD7cIni01N5zgEr0M2P+YBnlLzHjZ/ang0bRbSUW2HZJ1WGSs1Ae7hzS7te9NLfRw SNpbJc4qKM/cuZKYiccnZQtof6FOmHNTmR71/qQUmck+A9Z3i3YNdDkjIgubNuzEqxI3 akts1iDS6f+QDIYZwwX760ePCU1pjdch6OnDyrxdW+Ve1w/v0M63yFD9ZBEILFuy7Ag9 HGW3SxAhLOvfmfNLZ0fmqucLqM2MxezI0lrezOAMT3ezdktgalKo6M2gRLMsabSn2W3s Gusw== 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=BU+SHGSskHVHU6Nsjn7eGQFYG2ijLbi0WBESSe9Kn3I=; b=R613oGDz67PwRPx9C1ooBgoYHosxRng1+cQiDYzgyPE25oOwOV9scPeu6jjq+ZaKmz AGziG6fQzjsDgH9SwkldfykIaNTuR01WZehgq83GmpSF+P5H5QYWxtmIXtPlYxrQv5hj YfYmENiSepbt9U0v9gSdQfhceVNg6qPpkFSLX4Ox60Osrd/DVtnaBALLMxCb6XcNo/XA Eg54ytYKmS8Z5fFYYn7+WPdQxjI3HSF2gFVXnRVvFmxke35jKJSI0z8EgZ36o7pxDsHn tC8kNZMiUJqiOGMfm7TePiFiekRXCL3XtJqFl4lnbh0v+cJEaYf3zh9P6ksQcJYA+i2B tZMQ== 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 bt14-20020a056512260e00b00492cf527b2bsi444692lfb.33.2022.09.08.22.55.36; Thu, 08 Sep 2022 22:56:05 -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 S229969AbiIIFnM (ORCPT + 99 others); Fri, 9 Sep 2022 01:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbiIIFnL (ORCPT ); Fri, 9 Sep 2022 01:43:11 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E7C80B4C; Thu, 8 Sep 2022 22:43:09 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VP83TeQ_1662702166; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VP83TeQ_1662702166) by smtp.aliyun-inc.com; Fri, 09 Sep 2022 13:43:06 +0800 From: Jiapeng Chong To: borisp@nvidia.com Cc: saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] net/mlx5: use kmemdup() to replace kzalloc + memcpy Date: Fri, 9 Sep 2022 13:42:44 +0800 Message-Id: <20220909054244.73956-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,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, 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 ./drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c:932:27-34: WARNING opportunity for kmemdup. Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2107 Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c index d9d18b039d8c..e32892943ee5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -929,14 +929,13 @@ static int mlx5e_macsec_add_secy(struct macsec_context *ctx) goto out; } - macsec_device->dev_addr = kzalloc(dev->addr_len, GFP_KERNEL); + macsec_device->dev_addr = kmemdup(dev->dev_addr, dev->addr_len, GFP_KERNEL); if (!macsec_device->dev_addr) { kfree(macsec_device); err = -ENOMEM; goto out; } - memcpy(macsec_device->dev_addr, dev->dev_addr, dev->addr_len); macsec_device->netdev = dev; INIT_LIST_HEAD_RCU(&macsec_device->macsec_rx_sc_list_head); -- 2.20.1.7.g153144c