linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: gpiolib: replace deprecated strcpy() with strscpy()
@ 2025-11-01  7:41 Dmitry Antipov
  2025-11-01  7:41 ` [PATCH] gpio: virtuser: avoid strlen() in gpio_virtuser_direction_do_read() Dmitry Antipov
  2025-11-10 22:06 ` [PATCH] gpio: gpiolib: replace deprecated strcpy() with strscpy() Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Antipov @ 2025-11-01  7:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij; +Cc: linux-gpio, Dmitry Antipov

Prefer 'strscpy()' over deprecated 'strcpy()' in 'desc_set_label()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/gpio/gpiolib.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 9952e412da50..5c0cd096642b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -146,12 +146,13 @@ static int desc_set_label(struct gpio_desc *desc, const char *label)
 	struct gpio_desc_label *new = NULL, *old;
 
 	if (label) {
-		new = kzalloc(struct_size(new, str, strlen(label) + 1),
-			      GFP_KERNEL);
+		int size = strlen(label) + 1;
+
+		new = kzalloc(struct_size(new, str, size), GFP_KERNEL);
 		if (!new)
 			return -ENOMEM;
 
-		strcpy(new->str, label);
+		strscpy(new->str, label, size);
 	}
 
 	old = rcu_replace_pointer(desc->label, new, 1);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-12  9:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-01  7:41 [PATCH] gpio: gpiolib: replace deprecated strcpy() with strscpy() Dmitry Antipov
2025-11-01  7:41 ` [PATCH] gpio: virtuser: avoid strlen() in gpio_virtuser_direction_do_read() Dmitry Antipov
2025-11-10 22:07   ` Linus Walleij
2025-11-12  9:43     ` Andy Shevchenko
2025-11-10 22:06 ` [PATCH] gpio: gpiolib: replace deprecated strcpy() with strscpy() Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).