public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Ganesh Kumar Pittala <ganeshkpittala@gmail.com>
To: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org
Cc: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, hvaibhav.linux@gmail.com,
	vaibhav.sr@gmail.com, mgreer@animalcreek.com, rmfrfs@gmail.com,
	pure.logic@nexus-software.ie, ganeshkpittala@gmail.com
Subject: [PATCH v2 1/4] staging: greybus: replace deprecated strncpy with strscpy in firmware.c
Date: Sun, 13 Apr 2025 07:32:17 +0000	[thread overview]
Message-ID: <20250413073220.15931-2-ganeshkpittala@gmail.com> (raw)
In-Reply-To: <20250413073220.15931-1-ganeshkpittala@gmail.com>

This patch replaces the use of the deprecated strncpy() function with
strscpy() in drivers/staging/greybus/Documentation/firmware/firmware.c.

The strscpy() API is the recommended safer alternative that guarantees
NUL-termination and avoids potential buffer overflows, making it more
robust for handling string operations in kernel space.

This change improves code safety and aligns the driver with current
kernel coding practices.

Signed-off-by: Ganesh Kumar Pittala <ganeshkpittala@gmail.com>
---
 drivers/staging/greybus/Documentation/firmware/firmware.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/drivers/staging/greybus/Documentation/firmware/firmware.c
index 765d69faa9cc..f37904b914d2 100644
--- a/drivers/staging/greybus/Documentation/firmware/firmware.c
+++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
@@ -63,7 +63,7 @@ static int update_intf_firmware(int fd)
 	intf_load.major = 0;
 	intf_load.minor = 0;
 
-	strncpy((char *)&intf_load.firmware_tag, firmware_tag,
+	strscpy((char *)&intf_load.firmware_tag, firmware_tag,
 		GB_FIRMWARE_U_TAG_MAX_SIZE);
 
 	ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
@@ -101,7 +101,7 @@ static int update_backend_firmware(int fd)
 	/* Get Backend Firmware Version */
 	printf("Getting Backend Firmware Version\n");
 
-	strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
+	strscpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
 		GB_FIRMWARE_U_TAG_MAX_SIZE);
 
 retry_fw_version:
@@ -129,7 +129,7 @@ static int update_backend_firmware(int fd)
 	/* Try Backend Firmware Update over Unipro */
 	printf("Updating Backend Firmware\n");
 
-	strncpy((char *)&backend_update.firmware_tag, firmware_tag,
+	strscpy((char *)&backend_update.firmware_tag, firmware_tag,
 		GB_FIRMWARE_U_TAG_MAX_SIZE);
 
 retry_fw_update:
-- 
2.43.0


  reply	other threads:[~2025-04-13  7:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-13  7:32 [PATCH v2 0/4] staging: greybus: cleanup, API migration, and refactors Ganesh Kumar Pittala
2025-04-13  7:32 ` Ganesh Kumar Pittala [this message]
2025-04-16 19:54   ` [greybus-dev] [PATCH v2 1/4] staging: greybus: replace deprecated strncpy with strscpy in firmware.c Jeff Johnson
2025-04-13  7:32 ` [PATCH v2 2/4] staging: greybus: replace sprintf with sysfs_emit in sysfs show functions Ganesh Kumar Pittala
2025-04-13  7:32 ` [PATCH v2 3/4] staging: greybus: refactor gb_loopback_fn into smaller helper functions Ganesh Kumar Pittala
2025-04-17  9:09   ` Greg KH
2025-04-13  7:32 ` [PATCH v2 4/4] staging: greybus: split gb_audio_gb_get_topology into " Ganesh Kumar Pittala
2025-04-17  9:03 ` [PATCH v2 0/4] staging: greybus: cleanup, API migration, and refactors Greg KH

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=20250413073220.15931-2-ganeshkpittala@gmail.com \
    --to=ganeshkpittala@gmail.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=hvaibhav.linux@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mgreer@animalcreek.com \
    --cc=pure.logic@nexus-software.ie \
    --cc=rmfrfs@gmail.com \
    --cc=vaibhav.sr@gmail.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