Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dmitry Antipov and committed by
Paul Moore
d1a09195 fe3c03b8

+5 -5
+5 -5
security/inode.c
··· 30 30 static void securityfs_free_inode(struct inode *inode) 31 31 { 32 32 if (S_ISLNK(inode->i_mode)) 33 - kfree(inode->i_link); 33 + kfree_const(inode->i_link); 34 34 free_inode_nonrcu(inode); 35 35 } 36 36 ··· 258 258 const struct inode_operations *iops) 259 259 { 260 260 struct dentry *dent; 261 - char *link = NULL; 261 + const char *link = NULL; 262 262 263 263 if (target) { 264 - link = kstrdup(target, GFP_KERNEL); 264 + link = kstrdup_const(target, GFP_KERNEL); 265 265 if (!link) 266 266 return ERR_PTR(-ENOMEM); 267 267 } 268 268 dent = securityfs_create_dentry(name, S_IFLNK | 0444, parent, 269 - link, NULL, iops); 269 + (void *)link, NULL, iops); 270 270 if (IS_ERR(dent)) 271 - kfree(link); 271 + kfree_const(link); 272 272 273 273 return dent; 274 274 }