mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
438c582602
commit
b3dd8957c2
@@ -126,9 +126,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
xattr->xe_namelen = strlen(xattr_name) + 1;
|
xattr->xe_name = kstrdup(xattr_name, GFP_NOFS);
|
||||||
|
|
||||||
xattr->xe_name = kzalloc(xattr->xe_namelen, GFP_NOFS);
|
|
||||||
if (!xattr->xe_name) {
|
if (!xattr->xe_name) {
|
||||||
CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
|
CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
|
||||||
xattr->xe_namelen);
|
xattr->xe_namelen);
|
||||||
@@ -141,7 +139,6 @@ static int ll_xattr_cache_add(struct list_head *cache,
|
|||||||
goto err_value;
|
goto err_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(xattr->xe_name, xattr_name, xattr->xe_namelen);
|
|
||||||
memcpy(xattr->xe_value, xattr_val, xattr_val_len);
|
memcpy(xattr->xe_value, xattr_val, xattr_val_len);
|
||||||
xattr->xe_vallen = xattr_val_len;
|
xattr->xe_vallen = xattr_val_len;
|
||||||
list_add(&xattr->xe_list, cache);
|
list_add(&xattr->xe_list, cache);
|
||||||
|
|||||||
Reference in New Issue
Block a user