summaryrefslogtreecommitdiff
path: root/fs/ubifs/xattr.c
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2011-11-18 00:00:52 +0100
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2011-11-22 10:58:48 +0200
commiteaecf43a6970c8d0ef54a31427c82a99e4863fe8 (patch)
tree998f383df3a68c34e08efb5064dfc82536af5a48 /fs/ubifs/xattr.c
parentcfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff)
UBIFS: Use kmemdup rather than duplicating its implementation
The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs/xattr.c')
-rw-r--r--fs/ubifs/xattr.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index bf18f7a04544..85b272268754 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -138,12 +138,11 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
ui = ubifs_inode(inode);
ui->xattr = 1;
ui->flags |= UBIFS_XATTR_FL;
- ui->data = kmalloc(size, GFP_NOFS);
+ ui->data = kmemdup(value, size, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_free;
}
- memcpy(ui->data, value, size);
inode->i_size = ui->ui_size = size;
ui->data_len = size;
@@ -204,12 +203,11 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
return err;
kfree(ui->data);
- ui->data = kmalloc(size, GFP_NOFS);
+ ui->data = kmemdup(value, size, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_free;
}
- memcpy(ui->data, value, size);
inode->i_size = ui->ui_size = size;
ui->data_len = size;