aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
authorMiklos Szeredi <mszeredi@redhat.com>2026-06-05 15:53:17 +0200
committerChristian Brauner <brauner@kernel.org>2026-06-06 15:21:40 +0200
commit832f4de4c8ba4f19e5df1d016a09917204b17834 (patch)
tree3c066606a8ba1b197b8f53de9c7ab3d9a3f47e69 /mm
parent6a07814ff643b5c8e1353d8c6229f52fde205cde (diff)
downloadath-832f4de4c8ba4f19e5df1d016a09917204b17834.tar.gz
tmpfs: simplify constructing "security.foo" xattr names
Use kasprintf() instead of doing it with kmalloc() + 2 x memcpy(). Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Link: https://patch.msgid.link/20260605135322.2632068-3-mszeredi@redhat.com Tested-by: Calum Mackay <calum.mackay@oracle.com> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 3b5dc21b323c2..c7897570fc9f9 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4232,7 +4232,6 @@ static int shmem_initxattrs(struct inode *inode,
struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
const struct xattr *xattr;
size_t ispace = 0;
- size_t len;
CLASS(simple_xattrs, xattrs)();
if (IS_ERR(xattrs))
@@ -4260,17 +4259,11 @@ static int shmem_initxattrs(struct inode *inode,
if (IS_ERR(new_xattr))
break;
- len = strlen(xattr->name) + 1;
- new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len,
- GFP_KERNEL_ACCOUNT);
+ new_xattr->name = kasprintf(GFP_KERNEL_ACCOUNT,
+ XATTR_SECURITY_PREFIX "%s", xattr->name);
if (!new_xattr->name)
break;
- memcpy(new_xattr->name, XATTR_SECURITY_PREFIX,
- XATTR_SECURITY_PREFIX_LEN);
- memcpy(new_xattr->name + XATTR_SECURITY_PREFIX_LEN,
- xattr->name, len);
-
if (simple_xattr_add(xattrs, new_xattr))
break;
retain_and_null_ptr(new_xattr);