diff options
| author | Dmitry Antipov <dmantipov@yandex.ru> | 2026-03-17 17:11:35 +0300 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2026-03-18 00:13:36 +0300 |
| commit | d1a09195866890ed4b407bf17879d2f7fa72d9a7 (patch) | |
| tree | 9086f336b05294196a082f9abc63818ed445e983 | |
| parent | fe3c03b84ae69f34992a5e72cbb8384b9ebad738 (diff) | |
| download | linux-d1a09195866890ed4b407bf17879d2f7fa72d9a7.tar.xz | |
securityfs: use kstrdup_const() to manage symlink targets
Since 'target' argument of 'securityfs_create_symlink()' is (for
now at least) a compile-time constant, it may be reasonable to
use 'kstrdup_const()' / 'kree_const()' to manage 'i_link' member
of the corresponding inode in attempt to reuse .rodata instance
rather than making a copy.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Paul Moore <paul@paul-moore.com>
| -rw-r--r-- | security/inode.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/security/inode.c b/security/inode.c index 81fb5d6dd33e..080402367674 100644 --- a/security/inode.c +++ b/security/inode.c @@ -30,7 +30,7 @@ static int mount_count; static void securityfs_free_inode(struct inode *inode) { if (S_ISLNK(inode->i_mode)) - kfree(inode->i_link); + kfree_const(inode->i_link); free_inode_nonrcu(inode); } @@ -258,17 +258,17 @@ struct dentry *securityfs_create_symlink(const char *name, const struct inode_operations *iops) { struct dentry *dent; - char *link = NULL; + const char *link = NULL; if (target) { - link = kstrdup(target, GFP_KERNEL); + link = kstrdup_const(target, GFP_KERNEL); if (!link) return ERR_PTR(-ENOMEM); } dent = securityfs_create_dentry(name, S_IFLNK | 0444, parent, - link, NULL, iops); + (void *)link, NULL, iops); if (IS_ERR(dent)) - kfree(link); + kfree_const(link); return dent; } |
