Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2637861pxb; Sun, 3 Oct 2021 01:11:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyYKjDi0pd97Ry3hjk2xBr1gY8qRlpsqz3/XPd5hYlsLsCAAhqA2NcOJGwdAfTzjHQCKI2 X-Received: by 2002:a17:906:3192:: with SMTP id 18mr8995859ejy.246.1633248711377; Sun, 03 Oct 2021 01:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633248711; cv=none; d=google.com; s=arc-20160816; b=HUutO+dsOmH/12gTZtoM75j9QJkYuaoGDsP4NHrrtY7mNGT4wruTy9DaE7XWcvcXzQ KE0eHJca12DcsAmuuQ20HlWdNuOBrwdJaWTad4ffrMah3VEmTmlIJdIN3zkVn2PdpNK8 J1tvrJaVYn7FWKN2ZwD25V+Jc2bZn0b14tdHdg70FvQYqVq+6OUvDXZQLiBNXToD7/bL 0FzMqYBRhn40fGB/B+mKnxzP1VYtPseiblh572pSnvFdTyX+xAHhsBudsQRpid2/QYKD s1CFxhgLd0lAXjLWSWxysUyWYU5q1TIuyX8GJdpj9tOO6OMZg2mMl7bvGxs9Ulksa4n7 INEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=RUnXu2XlUNXKn1vueWWq5KyrrUn700DzUS3jZaZPLio=; b=shLRg3PY1CpqWdYHGAKSoN3hbmSqHCZSzgNJ2MpdHmWiFvA8R71g8kySTphZfp3+nM 23V1Zkqi0q5j3Qnswku7GnjzTv4KECLRWQr/aajKs7an8XmiT4hhMp2iNOxA2fS/XNBf cU2MR2W3KKoN9LB1iF+6aGCK6Ng+kwY7ZunnTVC/HtLJkC0ti6z2yAFQfqGK4SodbTKY F2NKbwVchYUY/RzQiqx8jj2SapBlQyirHaD7UGiwBM5L15NE4Ziu1kXXSQHCsZY7zvM6 zNtciwsEA0PthAQyvcyAIiehQVdULjhVtzTjyqBc2vxKPXO08mH1wJu/2jrbS8YxAtPk vKsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si13999236edn.26.2021.10.03.01.10.54; Sun, 03 Oct 2021 01:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhJCIIx (ORCPT + 99 others); Sun, 3 Oct 2021 04:08:53 -0400 Received: from ssh248.corpemail.net ([210.51.61.248]:50126 "EHLO ssh248.corpemail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbhJCIIw (ORCPT ); Sun, 3 Oct 2021 04:08:52 -0400 Received: from ([60.208.111.195]) by ssh248.corpemail.net ((LNX1044)) with ASMTP (SSL) id XKK00156; Sun, 03 Oct 2021 16:06:56 +0800 Received: from localhost.localdomain (10.200.104.119) by jtjnmail201605.home.langchao.com (10.100.2.5) with Microsoft SMTP Server id 15.1.2308.14; Sun, 3 Oct 2021 16:06:58 +0800 From: Kai Song To: , , CC: , , Kai Song Subject: [PATCH] btrfs: zoned: Use kmemdup() to replace kmalloc + memcpy Date: Sun, 3 Oct 2021 16:06:56 +0800 Message-ID: <20211003080656.217151-1-songkai01@inspur.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.200.104.119] tUid: 20211003160656a3af2400dbd184062f23e01267357a2a X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fix memdup.cocci warning: fs/btrfs/zoned.c:1198:23-30: WARNING opportunity for kmemdup Signed-off-by: Kai Song --- fs/btrfs/zoned.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 1433ee220c94..cfa25f5ede0d 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1195,14 +1195,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) map = em->map_lookup; - cache->physical_map = kmalloc(map_lookup_size(map->num_stripes), GFP_NOFS); + cache->physical_map = kmemdup(map, map_lookup_size(map->num_stripes), GFP_NOFS); if (!cache->physical_map) { ret = -ENOMEM; goto out; } - memcpy(cache->physical_map, map, map_lookup_size(map->num_stripes)); - alloc_offsets = kcalloc(map->num_stripes, sizeof(*alloc_offsets), GFP_NOFS); if (!alloc_offsets) { ret = -ENOMEM; -- 2.27.0