diff mbox series

btrfs: fix memdup.cocci warnings

Message ID alpine.DEB.2.22.394.2009221219560.2659@hadrien
State New, archived
Headers show
Series btrfs: fix memdup.cocci warnings | expand

Commit Message

Julia Lawall Sept. 22, 2020, 10:21 a.m. UTC
From: kernel test robot <lkp@intel.com>

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 <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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(-)

Comments

Josef Bacik Sept. 22, 2020, 1:09 p.m. UTC | #1
On 9/22/20 6:21 AM, Julia Lawall wrote:
> From: kernel test robot <lkp@intel.com>
> 
> 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 <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
Filipe Manana Sept. 22, 2020, 2:05 p.m. UTC | #2
On Tue, Sep 22, 2020 at 11:29 AM Julia Lawall <julia.lawall@inria.fr> wrote:
>
> From: kernel test robot <lkp@intel.com>
>
> 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 <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>

Since this is not in Linus' tree yet, it can be folded in the original patch.
David, can you do that when you pick it?

Btw, isn't the Fixes tag meant only for bug fixes? This is a pure
cleanup afaics.

Thanks.

> ---
>
> 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);
David Sterba Sept. 22, 2020, 2:39 p.m. UTC | #3
On Tue, Sep 22, 2020 at 03:05:59PM +0100, Filipe Manana wrote:
> On Tue, Sep 22, 2020 at 11:29 AM Julia Lawall <julia.lawall@inria.fr> wrote:
> >
> > From: kernel test robot <lkp@intel.com>
> >
> > 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 <lkp@intel.com>
> > Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
> 
> Since this is not in Linus' tree yet, it can be folded in the original patch.
> David, can you do that when you pick it?

Yes, I'll do that.

> Btw, isn't the Fixes tag meant only for bug fixes? This is a pure
> cleanup afaics.

Agreed.
diff mbox series

Patch

--- 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);