From: David Laight Date: Sat, 6 Jun 2026 20:25:57 +0000 (+0100) Subject: gpiolib: Replace strcpy() with memcpy() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25afa211ae336569ddd0043f77e25e1b9b48c4d8;p=thirdparty%2Flinux.git gpiolib: Replace strcpy() with memcpy() The length of the string is calculated in order to allocate the correct sized memory block, use the same length to copy the string. Signed-off-by: David Laight Link: https://patch.msgid.link/20260606202633.5018-3-david.laight.linux@gmail.com Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ac2779dbe42b5..7bb6f114d64d9 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -143,13 +143,15 @@ static void desc_free_label(struct rcu_head *rh) static int desc_set_label(struct gpio_desc *desc, const char *label) { struct gpio_desc_label *new = NULL, *old; + size_t len; if (label) { - new = kzalloc_flex(*new, str, strlen(label) + 1); + len = strlen(label); + new = kzalloc_flex(*new, str, len + 1); if (!new) return -ENOMEM; - strcpy(new->str, label); + memcpy(new->str, label, len); } old = rcu_replace_pointer(desc->label, new, 1);