From patchwork Tue Sep 22 10:21:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 11792123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44C2F6CB for ; Tue, 22 Sep 2020 10:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 303752396D for ; Tue, 22 Sep 2020 10:28:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgIVK2c (ORCPT ); Tue, 22 Sep 2020 06:28:32 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:20393 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbgIVK2c (ORCPT ); Tue, 22 Sep 2020 06:28:32 -0400 X-Greylist: delayed 428 seconds by postgrey-1.27 at vger.kernel.org; Tue, 22 Sep 2020 06:28:31 EDT 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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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 Reviewed-by: Josef Bacik --- 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);