Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1146639pxb; Wed, 6 Apr 2022 09:48:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgmZEe3F6k043DNYrr+N+VzvwCw/vV0FEy1WuNHHRDckUseajuKsMqXwbRJDbhcJJTFJ+e X-Received: by 2002:a63:1f55:0:b0:382:65eb:3073 with SMTP id q21-20020a631f55000000b0038265eb3073mr8026816pgm.624.1649263706702; Wed, 06 Apr 2022 09:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649263706; cv=none; d=google.com; s=arc-20160816; b=dPkQS9uo4TeA/xam6zNs9AAWBdKXUeapqEUC6DNRIwP0/lnfixi0VbdzOrtpklvzoz YL/eOBTJy90DOTSos86BCU0r000XQypdIrilh+vx0Im4nCbHf9bWlxWx0bFez3GLKOLw fkeUQXfeDD5xO9HNAeAK9wxKyr/cdOLDQ6EeKeS4TOOwzhw7MxWgNW3FW/GsBeDx7Ehj 4FbCMkvv9wHSX2cWBXJI+h7c2vSc/wjvy5ME8b6I0q+2pZ9UZAlpLwz1KhoGjQQOg0ih K20HlryhPft0SrbyeHuB3ufzqhICHE4aChEzNJnD8VA7a5uxroGZT4deAWzh7BdhEIyX Av3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=LeXN+t76bBU9s00CgAYnpktRM3AfvFI1g3fw6xn0MY4=; b=aukPCdIVoSjSRylGoCNpKG5/BR44BuFVu71FahRj9H2ChlzwTPJiAuTDEEXmg5CqAp 7w+An+alkbk4MnrDGRwuAbcqqAj/Rk3mP80q/WhvG+2KzixWtwuoYDMmMBZvNHgKktZD crCztjzDMlRpVfqEE0fMRu6sR0s61IWvH0bxe7SBkGij13RsOM0+Jc7pDOH0PigrzDHt pGzUa+5Z7V65Uj2G6I2zUrazyXPjOxv0UCVzdXJ2oUYMRrYCvI5jap8XiOz7yyeo9DTG Gse9JvFFscmicSOEhL5mSE33EgvKyfVT/Nb3yvgESvup+b/jSLPzCdTtpSAs8el+48D7 l4nw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l7-20020a170903120700b00153fedfb358si18225745plh.599.2022.04.06.09.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:48:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30ED81F7639; Wed, 6 Apr 2022 09:22:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237688AbiDFQYO (ORCPT + 99 others); Wed, 6 Apr 2022 12:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbiDFQYH (ORCPT ); Wed, 6 Apr 2022 12:24:07 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9758627D22E; Wed, 6 Apr 2022 06:46:13 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KYN1j2jSLzBrvb; Wed, 6 Apr 2022 19:43:21 +0800 (CST) Received: from dggpemm500016.china.huawei.com (7.185.36.25) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 6 Apr 2022 19:47:32 +0800 Received: from huawei.com (10.67.174.102) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 6 Apr 2022 19:47:31 +0800 From: "GONG, Ruiqi" To: "David S . Miller" , Jakub Kicinski , Paolo Abeni CC: , , Wang Weiyang Subject: [PATCH] net: mpls: fix memdup.cocci warning Date: Wed, 6 Apr 2022 19:46:29 +0800 Message-ID: <20220406114629.182833-1-gongruiqi1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.102] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Simply use kmemdup instead of explicitly allocating and copying memory. Generated by: scripts/coccinelle/api/memdup.cocci Signed-off-by: GONG, Ruiqi --- net/mpls/af_mpls.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index d6fdc5782d33..35b5f806fdda 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1527,10 +1527,9 @@ static int mpls_ifdown(struct net_device *dev, int event) rt->rt_nh_size; struct mpls_route *orig = rt; - rt = kmalloc(size, GFP_KERNEL); + rt = kmemdup(orig, size, GFP_KERNEL); if (!rt) return -ENOMEM; - memcpy(rt, orig, size); } } -- 2.17.1