linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] phy: mscc: fix printf format
@ 2018-09-26 13:20 Arnd Bergmann
  2018-09-26 14:42 ` Alexandre Belloni
  2018-09-26 17:37 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-09-26 13:20 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David S. Miller
  Cc: Arnd Bergmann, Quentin Schulz, Alexandre Belloni, netdev, linux-kernel

gcc points out that the length of the temporary buffer may not be sufficient for
large numbers of leds:

drivers/net/phy/mscc.c: In function 'vsc85xx_probe':
drivers/net/phy/mscc.c:460:45: error: '-mode' directive writing 5 bytes into a region of size between 0 and 9 [-Werror=format-overflow=]
   ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
                                             ^~~~~
drivers/net/phy/mscc.c:460:9: note: 'sprintf' output between 19 and 28 bytes into a destination of size 22
   ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While we can make a reasonable assumption that the number of LEDs is small,
the cost of making the buffer a little bigger is insignificant as well.

Fixes: 11bfdabb7ff5 ("net: phy: mscc: factorize code for LEDs mode")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/phy/mscc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index 2d9676d78d3f..7d0384e26c99 100644
--- a/drivers/net/phy/mscc.c
+++ b/drivers/net/phy/mscc.c
@@ -453,7 +453,7 @@ static int vsc85xx_dt_led_modes_get(struct phy_device *phydev,
 				    u32 *default_mode)
 {
 	struct vsc8531_private *priv = phydev->priv;
-	char led_dt_prop[19];
+	char led_dt_prop[28];
 	int i, ret;
 
 	for (i = 0; i < priv->nleds; i++) {
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] phy: mscc: fix printf format
  2018-09-26 13:20 [PATCH net-next] phy: mscc: fix printf format Arnd Bergmann
@ 2018-09-26 14:42 ` Alexandre Belloni
  2018-09-26 17:37 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-09-26 14:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Quentin Schulz,
	netdev, linux-kernel

On 26/09/2018 15:20:11+0200, Arnd Bergmann wrote:
> gcc points out that the length of the temporary buffer may not be sufficient for
> large numbers of leds:
> 
> drivers/net/phy/mscc.c: In function 'vsc85xx_probe':
> drivers/net/phy/mscc.c:460:45: error: '-mode' directive writing 5 bytes into a region of size between 0 and 9 [-Werror=format-overflow=]
>    ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
>                                              ^~~~~
> drivers/net/phy/mscc.c:460:9: note: 'sprintf' output between 19 and 28 bytes into a destination of size 22
>    ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
>          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> While we can make a reasonable assumption that the number of LEDs is small,
> the cost of making the buffer a little bigger is insignificant as well.
> 
> Fixes: 11bfdabb7ff5 ("net: phy: mscc: factorize code for LEDs mode")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/net/phy/mscc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
> index 2d9676d78d3f..7d0384e26c99 100644
> --- a/drivers/net/phy/mscc.c
> +++ b/drivers/net/phy/mscc.c
> @@ -453,7 +453,7 @@ static int vsc85xx_dt_led_modes_get(struct phy_device *phydev,
>  				    u32 *default_mode)
>  {
>  	struct vsc8531_private *priv = phydev->priv;
> -	char led_dt_prop[19];
> +	char led_dt_prop[28];
>  	int i, ret;
>  
>  	for (i = 0; i < priv->nleds; i++) {
> -- 
> 2.18.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] phy: mscc: fix printf format
  2018-09-26 13:20 [PATCH net-next] phy: mscc: fix printf format Arnd Bergmann
  2018-09-26 14:42 ` Alexandre Belloni
@ 2018-09-26 17:37 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-09-26 17:37 UTC (permalink / raw)
  To: arnd
  Cc: andrew, f.fainelli, quentin.schulz, alexandre.belloni, netdev,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 26 Sep 2018 15:20:11 +0200

> gcc points out that the length of the temporary buffer may not be sufficient for
> large numbers of leds:
> 
> drivers/net/phy/mscc.c: In function 'vsc85xx_probe':
> drivers/net/phy/mscc.c:460:45: error: '-mode' directive writing 5 bytes into a region of size between 0 and 9 [-Werror=format-overflow=]
>    ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
>                                              ^~~~~
> drivers/net/phy/mscc.c:460:9: note: 'sprintf' output between 19 and 28 bytes into a destination of size 22
>    ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
>          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> While we can make a reasonable assumption that the number of LEDs is small,
> the cost of making the buffer a little bigger is insignificant as well.
> 
> Fixes: 11bfdabb7ff5 ("net: phy: mscc: factorize code for LEDs mode")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-26 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 13:20 [PATCH net-next] phy: mscc: fix printf format Arnd Bergmann
2018-09-26 14:42 ` Alexandre Belloni
2018-09-26 17:37 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).