diff options
author | Andrzej Hajda <a.hajda@samsung.com> | 2015-02-13 17:36:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 00:21:35 -0500 |
commit | 75287a677ba1beab7ca0db948468f44eb23a709f (patch) | |
tree | 94ce4c696199aac8372d9e6e5a5162bad64fc54c | |
parent | a4bb1e43e22d3cade8f942fc6f95920248eb2fd0 (diff) |
kernfs: convert node name allocation to kstrdup_const
sysfs frequently performs duplication of strings located in read-only
memory section. Replacing kstrdup by kstrdup_const allows to avoid such
operations.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Greg KH <greg@kroah.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/kernfs/dir.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 2d881b381d2b..35e40879860a 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -412,7 +412,7 @@ void kernfs_put(struct kernfs_node *kn) | |||
412 | if (kernfs_type(kn) == KERNFS_LINK) | 412 | if (kernfs_type(kn) == KERNFS_LINK) |
413 | kernfs_put(kn->symlink.target_kn); | 413 | kernfs_put(kn->symlink.target_kn); |
414 | if (!(kn->flags & KERNFS_STATIC_NAME)) | 414 | if (!(kn->flags & KERNFS_STATIC_NAME)) |
415 | kfree(kn->name); | 415 | kfree_const(kn->name); |
416 | if (kn->iattr) { | 416 | if (kn->iattr) { |
417 | if (kn->iattr->ia_secdata) | 417 | if (kn->iattr->ia_secdata) |
418 | security_release_secctx(kn->iattr->ia_secdata, | 418 | security_release_secctx(kn->iattr->ia_secdata, |
@@ -506,12 +506,12 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, | |||
506 | const char *name, umode_t mode, | 506 | const char *name, umode_t mode, |
507 | unsigned flags) | 507 | unsigned flags) |
508 | { | 508 | { |
509 | char *dup_name = NULL; | 509 | const char *dup_name = NULL; |
510 | struct kernfs_node *kn; | 510 | struct kernfs_node *kn; |
511 | int ret; | 511 | int ret; |
512 | 512 | ||
513 | if (!(flags & KERNFS_STATIC_NAME)) { | 513 | if (!(flags & KERNFS_STATIC_NAME)) { |
514 | name = dup_name = kstrdup(name, GFP_KERNEL); | 514 | name = dup_name = kstrdup_const(name, GFP_KERNEL); |
515 | if (!name) | 515 | if (!name) |
516 | return NULL; | 516 | return NULL; |
517 | } | 517 | } |
@@ -538,7 +538,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, | |||
538 | err_out2: | 538 | err_out2: |
539 | kmem_cache_free(kernfs_node_cache, kn); | 539 | kmem_cache_free(kernfs_node_cache, kn); |
540 | err_out1: | 540 | err_out1: |
541 | kfree(dup_name); | 541 | kfree_const(dup_name); |
542 | return NULL; | 542 | return NULL; |
543 | } | 543 | } |
544 | 544 | ||
@@ -1264,7 +1264,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, | |||
1264 | /* rename kernfs_node */ | 1264 | /* rename kernfs_node */ |
1265 | if (strcmp(kn->name, new_name) != 0) { | 1265 | if (strcmp(kn->name, new_name) != 0) { |
1266 | error = -ENOMEM; | 1266 | error = -ENOMEM; |
1267 | new_name = kstrdup(new_name, GFP_KERNEL); | 1267 | new_name = kstrdup_const(new_name, GFP_KERNEL); |
1268 | if (!new_name) | 1268 | if (!new_name) |
1269 | goto out; | 1269 | goto out; |
1270 | } else { | 1270 | } else { |
@@ -1297,7 +1297,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, | |||
1297 | kernfs_link_sibling(kn); | 1297 | kernfs_link_sibling(kn); |
1298 | 1298 | ||
1299 | kernfs_put(old_parent); | 1299 | kernfs_put(old_parent); |
1300 | kfree(old_name); | 1300 | kfree_const(old_name); |
1301 | 1301 | ||
1302 | error = 0; | 1302 | error = 0; |
1303 | out: | 1303 | out: |