Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3815694pxk; Tue, 22 Sep 2020 03:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWzOZMEvWmue4Zx51ZvHDy7Ms8KOszuVrehwzTi+Kql3DVXPBIxmcvOCKcxCNliTm45COw X-Received: by 2002:a17:906:194b:: with SMTP id b11mr4003641eje.159.1600770352238; Tue, 22 Sep 2020 03:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600770352; cv=none; d=google.com; s=arc-20160816; b=w5g1GC6feIKwWCiAjNAjqwavlSdB+/NtHpNjiz7gcy8Y2ZleKcHWjmbxzx1KA1M/uJ 9QDQPr2PCPvynhPO4RLBYAavPn1SHh/IxFTNKW2icTlZ+Wjn3r+LkM78Rm+wdS9QSLUt 6cd5DufIQjsNm1YTkNyWEDR4EIlEHQgzjCXYJ3zq2F0+HyF9N/uDU9QFmgN5WUtQb0UL g6UGJZHDzOV3mjaeVlvRfDCrS+PDgHsEXjZLiFfgwACPTt2JY9IW6kO4qgq4aHny7Pm0 xezjp2pGusOlZHcnlwBc2NMZY12aczMYr5bZtSzRpPlq4+UfRi8M8pkt7OibQz44aSs5 GRDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:subject:cc:to :from:date; bh=zBajgS0WYDoAu/7fcPFYEmpIuDrv0Phk+eHyIczdxKY=; b=M60FPpnDru6BQRoOrl2hCuvvz5X9UdwgOaq/nJn+BQ7V+Oorfeb/hCLTrTkC+HIxVl LgPNBp362ya33OiAtybRfavXgOwyvO3uISyVMkr3Ti/gU+BQu7tvJZ0S6QREm8z9/96e t0g0ni2hrTgea2PehtZzRPagYSfLaNnhdcBPvqrbodNOwDt4mK8btlqO7KZJ8YhoqpYB pS8SWtAbapHgM70KGz18YZD3GBVTRRnVtOHMfgtWgmxW4J31cOXYtxWsxDwUdLeq63BT mRRF8O+omWBjDJ5O/IK26B20VkyfvQB2raV9HV79wBlBGAmn2YLACnprH9Y0eySjdebq FuEQ== 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 a23si10311040ejk.229.2020.09.22.03.25.29; Tue, 22 Sep 2020 03:25:52 -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 S1726701AbgIVKV1 (ORCPT + 99 others); Tue, 22 Sep 2020 06:21:27 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:19694 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbgIVKVZ (ORCPT ); Tue, 22 Sep 2020 06:21:25 -0400 X-IronPort-AV: E=Sophos;i="5.77,290,1596492000"; d="scan'208";a="468931721" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2020 12:21:22 +0200 Date: Tue, 22 Sep 2020 12:21:21 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Filipe Manana cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kbuild-all@lists.01.org Subject: [PATCH] btrfs: fix memdup.cocci warnings Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kernel test robot fs/btrfs/send.c:3854:8-15: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Fixes: 28314eb24e6c ("btrfs: send, recompute reference path after orphanization of a directory") Signed-off-by: kernel test robot Signed-off-by: Julia Lawall --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git misc-next head: 28314eb24e6cb8124d1e5da2ef2ccb90ec44cc06 commit: 28314eb24e6cb8124d1e5da2ef2ccb90ec44cc06 [2/2] btrfs: send, recompute reference path after orphanization of a directory :::::: branch date: 17 hours ago :::::: commit date: 17 hours ago send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3851,10 +3851,9 @@ static int refresh_ref_path(struct send_ char *name; int ret; - name = kmalloc(ref->name_len, GFP_KERNEL); + name = kmemdup(ref->name, ref->name_len, GFP_KERNEL); if (!name) return -ENOMEM; - memcpy(name, ref->name, ref->name_len); fs_path_reset(ref->full_path); ret = get_cur_path(sctx, ref->dir, ref->dir_gen, ref->full_path);