diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-14 11:44:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-14 11:44:18 -0700 |
commit | be718b524d8d8a25c18b7403c4dbfddacc8e89e3 (patch) | |
tree | 8b14a6f2320c826d13ab6428f533067f286bfef4 /fs/configfs/item.c | |
parent | f66dc7232002f032ffd860940f98732898ebfd79 (diff) | |
parent | cc57c07343bd071cdf1915a91a24ab7d40c9b590 (diff) |
Merge tag 'configfs-for-4.19' of git://git.infradead.org/users/hch/configfs
Pull configfs updates from Christoph Hellwig:
- simplify the cide by using kvasprintf (Bart Van Assche)
- fix a gcc 8 string truncation warning by making the code simpler
(Guenter Roeck)
- fix a bug in rmdir() handling (Mike Christie)
* tag 'configfs-for-4.19' of git://git.infradead.org/users/hch/configfs:
configfs: fix registered group removal
configfs: replace strncpy with memcpy
configfs: use kvasprintf() instead of open-coding it
Diffstat (limited to 'fs/configfs/item.c')
-rw-r--r-- | fs/configfs/item.c | 24 |
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); |