Skip to contentSkip to conversation

devlink/param: replace deprecated strcpy() with strscpy()

PATCH In review Álvaro Costa 2 participants 2 messages Apr 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devlink/param: replace deprecated strcpy() with strscpy()

Replace strcpy() call used to extract a string parameter from param_data with strscpy(). Since strscpy() already performs bounds checking and ensures the destination string is NUL-terminated, remove the string length check as well.

---
 net/devlink/param.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/devlink/param.c +2 -4
index cf95268da5b0..26695b7e2861 100644
@@ -536,11 +536,9 @@ devlink_param_value_get_from_info(const struct devlink_param *param,
 		value->vu64 = nla_get_u64(param_data);
 		break;
 	case DEVLINK_PARAM_TYPE_STRING:
-		len = strnlen(nla_data(param_data), nla_len(param_data));
-		if (len == nla_len(param_data) ||
-		    len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
+		len = strscpy(value->vstr, nla_data(param_data));
+		if (len < 0)
 			return -EINVAL;
-		strcpy(value->vstr, nla_data(param_data));
 		break;
 	case DEVLINK_PARAM_TYPE_BOOL:
 		if (param_data && nla_len(param_data))
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 4 lines · On Thu, 23 Apr 2026 22:20:22 -0300 Álvaro Costa wrote:

Replace strcpy() call used to extract a string parameter from param_data with strscpy(). Since strscpy() already performs bounds checking and ensures the destination string is NUL-terminated, remove the string length check as well.

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.1, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after Apr 27th.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Signature · 2 lines
pw-bot: defer
pv-bot: closed