mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
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:
parent
07c44ee9fd
commit
25afa211ae
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user