* [PATCH] configfs: Use kvasprintf() instead of open-coding it
@ 2018-06-15 22:20 Bart Van Assche
2018-06-19 5:18 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2018-06-15 22:20 UTC (permalink / raw)
To: Joel Becker; +Cc: Christoph Hellwig, linux-kernel, Bart Van Assche
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
fs/configfs/item.c | 24 ++++--------------------
1 file 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);
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] configfs: Use kvasprintf() instead of open-coding it
2018-06-15 22:20 [PATCH] configfs: Use kvasprintf() instead of open-coding it Bart Van Assche
@ 2018-06-19 5:18 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2018-06-19 5:18 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Joel Becker, Christoph Hellwig, linux-kernel
Thanks Bart,
applied to the configfs tree for 4.19.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-19 5:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 22:20 [PATCH] configfs: Use kvasprintf() instead of open-coding it Bart Van Assche
2018-06-19 5:18 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.