From nobody Fri Apr 3 04:51:27 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13E50125B2 for ; Wed, 18 Mar 2026 00:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773792763; cv=none; b=f/YISDrNxTPkbn9L6nTG/wjq5F7WLQ9hAzGB3wPZDJHhdSdwV5pZZYuI5sbE7rHa8rlPA07g6aL0CHcb6m25A83aexVdrrkgrA+uyaXXLmYwl23dbmu2vb8s9hAva5j//hnI4iBdxY2+D7ojTKLm/tJ69/cwohdKfbJPk7F8WwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773792763; c=relaxed/simple; bh=/wyeoNSc8VJPOIxl4aULutCs+w8XFz29GTMzofX9+V0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mjfkpsBgVkOIiqVmToOXitLSpYCVd7L2rgAM0AhSX17IGn//Te2K3yTALxaWhIFtBOH08c5dxY1fjEZw2UFpl1extWngJ39eBgEpuMaSwQLgx4F//44y9msQVek6Ww0Exd4ORuLzvlAf3L5DnX8lTaZeQaMvWfgPx4CQ3sHcPJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VWKpqRM9; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VWKpqRM9" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773792759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=As+BWxwmhTP8TFNtZY1Ykz6cxDPrQsrHZiB+nEzMtOc=; b=VWKpqRM9yxsigYFoFfHyJ3mGh2sBjyW3ZWyMQpPj/uOS1OOiALo+93fYveNr6rBOLRmffc AvZ1Z9f+DhOWfnDVvpcgRIqAoc+d4Uw8+0laFPpIDwJi/IzOcwho0AP9z3OP+8p9TtJ8s8 PLzhjY1eY1WP6oqfSVkoFT/ni6zIpjo= From: Thorsten Blum To: Ian Kent Cc: Christian Brauner , Thorsten Blum , 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 Message-ID: <20260318001219.2354-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1862; i=thorsten.blum@linux.dev; h=from:subject; bh=/wyeoNSc8VJPOIxl4aULutCs+w8XFz29GTMzofX9+V0=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJk73z4+XXRBZM7eE8pMYc9jPm7ZEnU2rXjLMsGTv52rD xa07Gdo6ihlYRDjYpAVU2R5MOvHDN/SmspNJhE7YeawMoEMYeDiFICJREkzMnxafnmq+e/5fq31 PLzNjGkqh3UzZLTfxs/0nrWsYW9h53xGhqOhe+fO/bHXnF/620mtb7/d/kQumBLscniv6Etp53j XjWwA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Thorsten Blum --- 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 @@ =20 #include #include +#include =20 #include "autofs_i.h" =20 @@ -578,7 +579,6 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap, struct autofs_info *ino =3D autofs_dentry_ino(dentry); struct autofs_info *p_ino; struct inode *inode; - size_t size =3D strlen(symname); char *cp; =20 pr_debug("%s <- %pd\n", symname, dentry); @@ -589,19 +589,17 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap, =20 autofs_del_active(dentry); =20 - cp =3D kmalloc(size + 1, GFP_KERNEL); + cp =3D kstrdup(symname, GFP_KERNEL); if (!cp) return -ENOMEM; =20 - strcpy(cp, symname); - inode =3D autofs_get_inode(dir->i_sb, S_IFLNK | 0555); if (!inode) { kfree(cp); return -ENOMEM; } inode->i_private =3D cp; - inode->i_size =3D size; + inode->i_size =3D strlen(cp); =20 d_make_persistent(dentry, inode); p_ino =3D autofs_dentry_ino(dentry->d_parent);