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 <david.laight.linux@gmail.com>
Link: https://patch.msgid.link/20260606202633.5018-3-david.laight.linux@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
David Laight 2026-06-06 21:25:57 +01:00 committed by Bartosz Golaszewski
parent 07c44ee9fd
commit 25afa211ae

View File

@ -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);