[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z9mZFlDN9CegMVmH@smile.fi.intel.com>
Date: Tue, 18 Mar 2025 18:02:30 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Lee Jones <lee@...nel.org>, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Pavel Machek <pavel@...nel.org>
Subject: Re: [PATCH v1 1/1] leds: core: Bail out when composed name can't fit
the buffer
On Tue, Mar 18, 2025 at 05:51:25PM +0200, Andy Shevchenko wrote:
> GCC compiler complains about snprintf() calls that may potentially cut
> the output:
>
> drivers/leds/led-core.c:551:78: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
> drivers/leds/led-core.c:554:78: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
> ...
>
> Fix these by checking for the potential overflow. This requires
> to align all the branches to use the same callee, i.e. snprintf(),
> otherwise the code will be blown up and return different error codes
> for the different branches.
...
> - strscpy(led_classdev_name, to_of_node(fwnode)->name,
> - LED_MAX_NAME_SIZE);
> + n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%pfw", fwnode);
Actually this is not an equivalent, should still have that ugly
to_of_node()->name...
I'll fix it in v2.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists