aboutsummaryrefslogtreecommitdiffstats
path: root/fs/configfs/item.c
diff options
context:
space:
mode:
authorJames Morris <james.morris@microsoft.com>2018-09-04 11:35:54 -0700
committerJames Morris <james.morris@microsoft.com>2018-09-04 11:35:54 -0700
commite42f6f9be4f83c537aa81b4c6239ea94ff5b29ce (patch)
treef956a5ea0e83fc6d0df3e64681e7bbc1f201f3ee /fs/configfs/item.c
parentsecurity/capabilities: remove check for -EINVAL (diff)
parentLinux 4.19-rc2 (diff)
downloadlinux-dev-e42f6f9be4f83c537aa81b4c6239ea94ff5b29ce.tar.xz
linux-dev-e42f6f9be4f83c537aa81b4c6239ea94ff5b29ce.zip
Merge tag 'v4.19-rc2' into next-general
Sync to Linux 4.19-rc2 for downstream developers.
Diffstat (limited to '')
-rw-r--r--fs/configfs/item.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index 88f266efc09b..99d491cd01f9 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -64,7 +64,6 @@ static void config_item_init(struct config_item *item)
*/
int config_item_set_name(struct config_item *item, const char *fmt, ...)
{
- int error = 0;
int limit = CONFIGFS_ITEM_NAME_LEN;
int need;
va_list args;
@@ -79,25 +78,11 @@ int config_item_set_name(struct config_item *item, const char *fmt, ...)
if (need < limit)
name = item->ci_namebuf;
else {
- /*
- * Need more space? Allocate it and try again
- */
- limit = need + 1;
- name = kmalloc(limit, GFP_KERNEL);
- if (!name) {
- error = -ENOMEM;
- goto Done;
- }
va_start(args, fmt);
- need = vsnprintf(name, limit, fmt, args);
+ name = kvasprintf(GFP_KERNEL, fmt, args);
va_end(args);
-
- /* Still? Give up. */
- if (need >= limit) {
- kfree(name);
- error = -EFAULT;
- goto Done;
- }
+ if (!name)
+ return -EFAULT;
}
/* Free the old name, if necessary. */
@@ -106,8 +91,7 @@ int config_item_set_name(struct config_item *item, const char *fmt, ...)
/* Now, set the new name */
item->ci_name = name;
- Done:
- return error;
+ return 0;
}
EXPORT_SYMBOL(config_item_set_name);