]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging/lustre: use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 7 Aug 2015 07:59:25 +0000 (09:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Aug 2015 22:16:58 +0000 (15:16 -0700)
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/acl.c

index bc3fc4780cb9e53f7faf61ac5f75d395943de8b8..933456c502d1ce2bfd9797ff7fad3dfea1946db0 100644 (file)
@@ -104,11 +104,10 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
        if (unlikely(old_count <= new_count))
                return old_size;
 
-       new = kzalloc(new_size, GFP_NOFS);
+       new = kmemdup(*header, new_size, GFP_NOFS);
        if (unlikely(new == NULL))
                return -ENOMEM;
 
-       memcpy(new, *header, new_size);
        kfree(*header);
        *header = new;
        return new_size;
@@ -125,11 +124,10 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header,
        if (unlikely(old_count <= ext_count))
                return 0;
 
-       new = kzalloc(ext_size, GFP_NOFS);
+       new = kmemdup(*header, ext_size, GFP_NOFS);
        if (unlikely(new == NULL))
                return -ENOMEM;
 
-       memcpy(new, *header, ext_size);
        kfree(*header);
        *header = new;
        return 0;