Re: [PATCH 1/4] leds: netdev trigger: use memcpy in device_name_store
From: Uwe Kleine-König
Date: Thu Mar 14 2019 - 05:29:34 EST
Hello,
On Wed, Mar 13, 2019 at 09:26:12PM +0100, Rasmus Villemoes wrote:
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -122,7 +122,8 @@ static ssize_t device_name_store(struct device *dev,
> trigger_data->net_dev = NULL;
> }
>
> - strncpy(trigger_data->device_name, buf, size);
> + memcpy(trigger_data->device_name, buf, size);
> + trigger_data->device_name[size] = '\0';
This is open-coding
strlcpy(trigger_data->device_name, buf, size);
Best regards
Uwe
> if (size > 0 && trigger_data->device_name[size - 1] == '\n')
> trigger_data->device_name[size - 1] = 0;
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |