[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190314092929.65amwzsaswcvsexl@pengutronix.de>
Date: Thu, 14 Mar 2019 10:29:29 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Pavel Machek <pavel@....cz>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
LKML <linux-kernel@...r.kernel.org>, linux-leds@...r.kernel.org
Subject: Re: [PATCH 1/4] leds: netdev trigger: use memcpy in device_name_store
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/ |
Powered by blists - more mailing lists