From: Rahul Kumar <rk0006818@gmail.com>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
rk0006818@gmail.com
Subject: [PATCH] mtd: sm_ftl: replace strncpy with memcpy
Date: Wed, 3 Sep 2025 17:47:46 +0530 [thread overview]
Message-ID: <20250903121746.2527046-1-rk0006818@gmail.com> (raw)
Replace strncpy with memcpy in sm_attr_show and explicitly add a NUL
terminator after the copy. This aligns with current kernel best practices
as strncpy is deprecated for such use, as explained in
Documentation/process/deprecated.rst. This change does not alter the
functionality or introduce any behavioral changes.
Signed-off-by: Rahul Kumar <rk0006818@gmail.com>
---
drivers/mtd/sm_ftl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index abc7b186353f..575e137ce8f3 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -44,7 +44,8 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
struct sm_sysfs_attribute *sm_attr =
container_of(attr, struct sm_sysfs_attribute, dev_attr);
- strncpy(buf, sm_attr->data, sm_attr->len);
+ memcpy(buf, sm_attr->data, sm_attr->len);
+ buf[sm_attr->len] = '\0';
return sm_attr->len;
}
--
2.43.0
next reply other threads:[~2025-09-03 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 12:17 Rahul Kumar [this message]
2025-09-03 14:28 ` [PATCH] mtd: sm_ftl: replace strncpy with memcpy Pratyush Yadav
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=20250903121746.2527046-1-rk0006818@gmail.com \
--to=rk0006818@gmail.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=skhan@linuxfoundation.org \
--cc=vigneshr@ti.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox