* [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup()
@ 2026-06-30 14:49 Thorsten Blum
2026-08-14 12:26 ` Christophe Leroy (CS GROUP)
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-06-30 14:49 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Kees Cook
Cc: Thorsten Blum, linuxppc-dev, linux-kernel
While the current code works correctly, replace the unbounded sprintf()
with the safer snprintf() in fsl_rio_setup() to follow secure coding
best practices.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/powerpc/sysdev/fsl_rio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index eb55dabb4748..077c03cd93e4 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -612,7 +612,7 @@ static int fsl_rio_setup(struct platform_device *dev)
kfree(port);
continue;
}
- sprintf(port->name, "RIO mport %d", i);
+ snprintf(port->name, sizeof(port->name), "RIO mport %d", i);
priv->dev = &dev->dev;
port->dev.parent = &dev->dev;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup()
2026-06-30 14:49 [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup() Thorsten Blum
@ 2026-08-14 12:26 ` Christophe Leroy (CS GROUP)
2026-08-14 14:46 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-08-14 12:26 UTC (permalink / raw)
To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
Nicholas Piggin, Kees Cook
Cc: linuxppc-dev, linux-kernel
Le 30/06/2026 à 16:49, Thorsten Blum a écrit :
> While the current code works correctly, replace the unbounded sprintf()
> with the safer snprintf() in fsl_rio_setup() to follow secure coding
> best practices.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/powerpc/sysdev/fsl_rio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
> index eb55dabb4748..077c03cd93e4 100644
> --- a/arch/powerpc/sysdev/fsl_rio.c
> +++ b/arch/powerpc/sysdev/fsl_rio.c
> @@ -612,7 +612,7 @@ static int fsl_rio_setup(struct platform_device *dev)
> kfree(port);
> continue;
> }
> - sprintf(port->name, "RIO mport %d", i);
> + snprintf(port->name, sizeof(port->name), "RIO mport %d", i);
Are you sure it is correct ?
Shouldn't it be sizeof(port->name) - 1 ?
>
> priv->dev = &dev->dev;
> port->dev.parent = &dev->dev;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup()
2026-08-14 12:26 ` Christophe Leroy (CS GROUP)
@ 2026-08-14 14:46 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-08-14 14:46 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin, Kees Cook,
linuxppc-dev, linux-kernel
On Fri, Aug 14, 2026 at 02:26:24PM +0200, Christophe Leroy (CS GROUP) wrote:
> Le 30/06/2026 à 16:49, Thorsten Blum a écrit :
> > While the current code works correctly, replace the unbounded sprintf()
> > with the safer snprintf() in fsl_rio_setup() to follow secure coding
> > best practices.
> >
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> > arch/powerpc/sysdev/fsl_rio.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
> > index eb55dabb4748..077c03cd93e4 100644
> > --- a/arch/powerpc/sysdev/fsl_rio.c
> > +++ b/arch/powerpc/sysdev/fsl_rio.c
> > @@ -612,7 +612,7 @@ static int fsl_rio_setup(struct platform_device *dev)
> > kfree(port);
> > continue;
> > }
> > - sprintf(port->name, "RIO mport %d", i);
> > + snprintf(port->name, sizeof(port->name), "RIO mport %d", i);
>
> Are you sure it is correct ?
>
> Shouldn't it be sizeof(port->name) - 1 ?
snprintf() takes the destination buffer size (including the NUL) as its
second argument, so sizeof(port->name) should be correct.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-14 14:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 14:49 [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup() Thorsten Blum
2026-08-14 12:26 ` Christophe Leroy (CS GROUP)
2026-08-14 14:46 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox