From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3788605255065332280==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] btrfs: fix memdup.cocci warnings Date: Tue, 13 Oct 2020 10:13:11 +0800 Message-ID: <20201013021311.GA63326@785ed4649015> In-Reply-To: <202010131036.a2cOL8dJ-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============3788605255065332280== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Filipe Manana CC: Chris Mason CC: Josef Bacik CC: David Sterba CC: linux-btrfs(a)vger.kernel.org CC: linux-kernel(a)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 orphaniza= tion of a directory") Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git = misc-next head: fdde80f42dc3e822ab990d28d584175eb0ca222f commit: 28314eb24e6cb8124d1e5da2ef2ccb90ec44cc06 [2/7] btrfs: send, recompu= te reference path after orphanization of a directory :::::: branch date: 15 hours ago :::::: commit date: 3 weeks ago Please take the patch only if it's a positive warning. Thanks! 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 =3D kmalloc(ref->name_len, GFP_KERNEL); + name =3D 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 =3D get_cur_path(sctx, ref->dir, ref->dir_gen, ref->full_path); --===============3788605255065332280==--