From: Thorsten Blum <thorsten.blum@linux.dev>
To: Ian Kent <raven@themaw.net>
Cc: Christian Brauner <brauner@kernel.org>,
Thorsten Blum <thorsten.blum@linux.dev>,
autofs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink
Date: Wed, 18 Mar 2026 01:12:21 +0100 [thread overview]
Message-ID: <20260318001219.2354-3-thorsten.blum@linux.dev> (raw)
The symlink name was previously duplicated using an explicit kmalloc()
followed by strcpy(), which is deprecated [1]. Replace this open-coded
string duplication with kstrdup(), which allocates and copies the
symlink name with a single helper function.
Remove the local variable 'size' and set 'i_size' directly using
strlen(cp), which is equivalent to the previous value of 'size'.
This simplifies the code, uses common string-handling helpers, and
removes the deprecated use of strcpy().
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/autofs/root.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 2c31002b314a..186e960f1e23 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/compat.h>
+#include <linux/string.h>
#include "autofs_i.h"
@@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
struct autofs_info *ino = autofs_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
- size_t size = strlen(symname);
char *cp;
pr_debug("%s <- %pd\n", symname, dentry);
@@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
autofs_del_active(dentry);
- cp = kmalloc(size + 1, GFP_KERNEL);
+ cp = kstrdup(symname, GFP_KERNEL);
if (!cp)
return -ENOMEM;
- strcpy(cp, symname);
-
inode = autofs_get_inode(dir->i_sb, S_IFLNK | 0555);
if (!inode) {
kfree(cp);
return -ENOMEM;
}
inode->i_private = cp;
- inode->i_size = size;
+ inode->i_size = strlen(cp);
d_make_persistent(dentry, inode);
p_ino = autofs_dentry_ino(dentry->d_parent);
next reply other threads:[~2026-03-18 0:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 0:12 Thorsten Blum [this message]
2026-03-18 9:56 ` [PATCH RESEND] autofs: replace manual symlink buffer allocation in autofs_dir_symlink Christian Brauner
2026-03-18 9:56 ` Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2026-01-27 1:36 Thorsten Blum
2026-01-27 2:14 ` Ian Kent
2026-02-22 21:22 ` Thorsten Blum
2026-01-05 12:43 Thorsten Blum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260318001219.2354-3-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=autofs@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.