diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 839e71e78673fd6846b2e4515532de6edf6d2d57..79369c13cc55780d06ef382940e4b2c029212a38 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -532,11 +532,10 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
 
 			unlock_buffer(bh);
 			ea_bdebug(bh, "cloning");
-			header = kmalloc(bh->b_size, GFP_KERNEL);
+			header = kmemdup(HDR(bh), bh->b_size, GFP_KERNEL);
 			error = -ENOMEM;
 			if (header == NULL)
 				goto cleanup;
-			memcpy(header, HDR(bh), bh->b_size);
 			header->h_refcount = cpu_to_le32(1);
 
 			offset = (char *)here - bh->b_data;