Re: [PATCH v1 1/1] leds: core: Bail out when composed name can't fit the buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux