Re: [PATCH net v2 2/2] net: usb: asix: ax88772: Increase phy_name size
From: Andy Shevchenko
Date: Wed Mar 19 2025 - 07:26:55 EST
On Wed, Mar 19, 2025 at 12:54:34PM +0200, Andy Shevchenko wrote:
> GCC compiler (Debian 14.2.0-17) is not happy about printing
> into a short buffer (when build with `make W=1`):
>
> drivers/net/usb/ax88172a.c: In function ‘ax88172a_reset’:
> include/linux/phy.h:312:20: error: ‘%s’ directive output may be truncated writing up to 60 bytes into a region of size 20 [-Werror=format-truncation=]
>
> Indeed, the buffer size is chosen based on some assumptions, while
> in general the assigned name might not fit. Increase the buffer to
> cover maximum length of the parameters. With that, change snprintf()
> to use sizeof() instead of hard coded number.
...
> if (ret < 0)
> goto free;
> -
> + if (ret >= PHY_MAX_ADDR) {
> + netdev_err(dev->net, "Invalid PHY ID %x\n", ret);
> + return -ENODEV;
Oh, I was blindly put what had been suggested, needs a fix, but I will wait for
other comments if any before issuing a v3.
> + }
--
With Best Regards,
Andy Shevchenko