summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapasweni Pathak <tapaswenipathak@gmail.com>2014-10-24 21:46:00 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-10-27 10:33:05 +0800
commitb3dd8957c23a9e2eed612469d02a6e418b585e6b (patch)
tree0e93541f176221ac1482ce62fff096513ec649c4
parent438c582602b9e0b421bd356f3f2cdc77fe45eb5b (diff)
staging: lustre: lustre: llite: Use kstrdup
Use kstrdup when the goal of an allocation is copy a string into the allocated region. Patch found by coccicheck. Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr_cache.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c
index 627cbe242f2..e2badf17d95 100644
--- a/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -126,9 +126,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
return -ENOMEM;
}
- xattr->xe_namelen = strlen(xattr_name) + 1;
-
- xattr->xe_name = kzalloc(xattr->xe_namelen, GFP_NOFS);
+ xattr->xe_name = kstrdup(xattr_name, GFP_NOFS);
if (!xattr->xe_name) {
CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
xattr->xe_namelen);
@@ -141,7 +139,6 @@ static int ll_xattr_cache_add(struct list_head *cache,
goto err_value;
}
- memcpy(xattr->xe_name, xattr_name, xattr->xe_namelen);
memcpy(xattr->xe_value, xattr_val, xattr_val_len);
xattr->xe_vallen = xattr_val_len;
list_add(&xattr->xe_list, cache);