linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
@ 2024-01-11  8:27 Sergio Paracuellos
  2024-02-23 11:24 ` Sergio Paracuellos
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sergio Paracuellos @ 2024-01-11  8:27 UTC (permalink / raw)
  To: linux-pci
  Cc: bhelgaas, lpieralisi, kw, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel,
	Bjorn Helgaas

The following warning appears when driver is compiled with W=1.

CC      drivers/pci/controller/pcie-mt7621.o
drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
be truncated before the last format character [-Werror=format-truncation=]
228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
    |                                                 ^
drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
10 and 11 bytes into a destination of size 10
228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
    |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Clean this up increasing destination buffer one byte.

Reported-by: Bjorn Helgaas <helgaas@kernel.org>
Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/pci/controller/pcie-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-mt7621.c b/drivers/pci/controller/pcie-mt7621.c
index 79e225edb42a..d97b956e6e57 100644
--- a/drivers/pci/controller/pcie-mt7621.c
+++ b/drivers/pci/controller/pcie-mt7621.c
@@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
 	struct mt7621_pcie_port *port;
 	struct device *dev = pcie->dev;
 	struct platform_device *pdev = to_platform_device(dev);
-	char name[10];
+	char name[11];
 	int err;
 
 	port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
-- 
2.25.1


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

* Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
  2024-01-11  8:27 [PATCH] PCI: mt7621: Fix possible string truncation in snprintf Sergio Paracuellos
@ 2024-02-23 11:24 ` Sergio Paracuellos
  2024-04-11  9:12   ` Sergio Paracuellos
  2024-04-12 21:33 ` Bjorn Helgaas
  2024-05-17 11:29 ` Krzysztof Wilczyński
  2 siblings, 1 reply; 6+ messages in thread
From: Sergio Paracuellos @ 2024-02-23 11:24 UTC (permalink / raw)
  To: linux-pci
  Cc: bhelgaas, lpieralisi, kw, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel,
	Bjorn Helgaas

Hi,

On Thu, Jan 11, 2024 at 9:27 AM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> The following warning appears when driver is compiled with W=1.
>
> CC      drivers/pci/controller/pcie-mt7621.o
> drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> be truncated before the last format character [-Werror=format-truncation=]
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |                                                 ^
> drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> 10 and 11 bytes into a destination of size 10
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Clean this up increasing destination buffer one byte.
>
> Reported-by: Bjorn Helgaas <helgaas@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>  drivers/pci/controller/pcie-mt7621.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-mt7621.c b/drivers/pci/controller/pcie-mt7621.c
> index 79e225edb42a..d97b956e6e57 100644
> --- a/drivers/pci/controller/pcie-mt7621.c
> +++ b/drivers/pci/controller/pcie-mt7621.c
> @@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
>         struct mt7621_pcie_port *port;
>         struct device *dev = pcie->dev;
>         struct platform_device *pdev = to_platform_device(dev);
> -       char name[10];
> +       char name[11];
>         int err;
>
>         port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> --
> 2.25.1
>

Gentle ping on this patch :)

Thanks,
    Sergio Paracuellos

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

* Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
  2024-02-23 11:24 ` Sergio Paracuellos
@ 2024-04-11  9:12   ` Sergio Paracuellos
  0 siblings, 0 replies; 6+ messages in thread
From: Sergio Paracuellos @ 2024-04-11  9:12 UTC (permalink / raw)
  To: linux-pci
  Cc: bhelgaas, lpieralisi, kw, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel,
	Bjorn Helgaas

Hi,

On Fri, Feb 23, 2024 at 12:24 PM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> Hi,
>
> On Thu, Jan 11, 2024 at 9:27 AM Sergio Paracuellos
> <sergio.paracuellos@gmail.com> wrote:
> >
> > The following warning appears when driver is compiled with W=1.
> >
> > CC      drivers/pci/controller/pcie-mt7621.o
> > drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> > drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> > be truncated before the last format character [-Werror=format-truncation=]
> > 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
> >     |                                                 ^
> > drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> > 10 and 11 bytes into a destination of size 10
> > 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
> >     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Clean this up increasing destination buffer one byte.
> >
> > Reported-by: Bjorn Helgaas <helgaas@kernel.org>
> > Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t
> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> > ---
> >  drivers/pci/controller/pcie-mt7621.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mt7621.c b/drivers/pci/controller/pcie-mt7621.c
> > index 79e225edb42a..d97b956e6e57 100644
> > --- a/drivers/pci/controller/pcie-mt7621.c
> > +++ b/drivers/pci/controller/pcie-mt7621.c
> > @@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
> >         struct mt7621_pcie_port *port;
> >         struct device *dev = pcie->dev;
> >         struct platform_device *pdev = to_platform_device(dev);
> > -       char name[10];
> > +       char name[11];
> >         int err;
> >
> >         port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > --
> > 2.25.1
> >
>
> Gentle ping on this patch :)

Another gentle ping on this patch :)

Thanks,
    Sergio Paracuellos

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

* Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
  2024-01-11  8:27 [PATCH] PCI: mt7621: Fix possible string truncation in snprintf Sergio Paracuellos
  2024-02-23 11:24 ` Sergio Paracuellos
@ 2024-04-12 21:33 ` Bjorn Helgaas
  2024-04-13 10:10   ` Sergio Paracuellos
  2024-05-17 11:29 ` Krzysztof Wilczyński
  2 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2024-04-12 21:33 UTC (permalink / raw)
  To: Sergio Paracuellos
  Cc: linux-pci, bhelgaas, lpieralisi, kw, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel

On Thu, Jan 11, 2024 at 09:27:04AM +0100, Sergio Paracuellos wrote:
> The following warning appears when driver is compiled with W=1.
> 
> CC      drivers/pci/controller/pcie-mt7621.o
> drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> be truncated before the last format character [-Werror=format-truncation=]
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |                                                 ^
> drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> 10 and 11 bytes into a destination of size 10
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Clean this up increasing destination buffer one byte.
> 
> Reported-by: Bjorn Helgaas <helgaas@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>

Krzysztof applied this to pci/controller/mt7621 for v6.10, thanks!  I
just pulled that branch into "next", so it should appear in the next
linux-next.

> ---
>  drivers/pci/controller/pcie-mt7621.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-mt7621.c b/drivers/pci/controller/pcie-mt7621.c
> index 79e225edb42a..d97b956e6e57 100644
> --- a/drivers/pci/controller/pcie-mt7621.c
> +++ b/drivers/pci/controller/pcie-mt7621.c
> @@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
>  	struct mt7621_pcie_port *port;
>  	struct device *dev = pcie->dev;
>  	struct platform_device *pdev = to_platform_device(dev);
> -	char name[10];
> +	char name[11];
>  	int err;
>  
>  	port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> -- 
> 2.25.1
> 

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

* Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
  2024-04-12 21:33 ` Bjorn Helgaas
@ 2024-04-13 10:10   ` Sergio Paracuellos
  0 siblings, 0 replies; 6+ messages in thread
From: Sergio Paracuellos @ 2024-04-13 10:10 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, bhelgaas, lpieralisi, kw, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel

On Fri, Apr 12, 2024 at 11:33 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Thu, Jan 11, 2024 at 09:27:04AM +0100, Sergio Paracuellos wrote:
> > The following warning appears when driver is compiled with W=1.
> >
> > CC      drivers/pci/controller/pcie-mt7621.o
> > drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> > drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> > be truncated before the last format character [-Werror=format-truncation=]
> > 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
> >     |                                                 ^
> > drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> > 10 and 11 bytes into a destination of size 10
> > 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
> >     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Clean this up increasing destination buffer one byte.
> >
> > Reported-by: Bjorn Helgaas <helgaas@kernel.org>
> > Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t
> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
>
> Krzysztof applied this to pci/controller/mt7621 for v6.10, thanks!  I
> just pulled that branch into "next", so it should appear in the next
> linux-next.

Awesome. Thanks for letting me know.

Best regards,
    Sergio Paracuellos

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

* Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf
  2024-01-11  8:27 [PATCH] PCI: mt7621: Fix possible string truncation in snprintf Sergio Paracuellos
  2024-02-23 11:24 ` Sergio Paracuellos
  2024-04-12 21:33 ` Bjorn Helgaas
@ 2024-05-17 11:29 ` Krzysztof Wilczyński
  2 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Wilczyński @ 2024-05-17 11:29 UTC (permalink / raw)
  To: Sergio Paracuellos
  Cc: linux-pci, bhelgaas, lpieralisi, robh, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-kernel,
	Bjorn Helgaas

Hello,

> The following warning appears when driver is compiled with W=1.
> 
> CC      drivers/pci/controller/pcie-mt7621.o
> drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> be truncated before the last format character [-Werror=format-truncation=]
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |                                                 ^
> drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> 10 and 11 bytes into a destination of size 10
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Clean this up increasing destination buffer one byte.

Applied to controller/mt7621, thank you!

[1/1] PCI: mt7621: Fix string truncation in mt7621_pcie_parse_port()
      https://git.kernel.org/pci/pci/c/fd6eb49a84a8

	Krzysztof

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

end of thread, other threads:[~2024-05-17 11:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  8:27 [PATCH] PCI: mt7621: Fix possible string truncation in snprintf Sergio Paracuellos
2024-02-23 11:24 ` Sergio Paracuellos
2024-04-11  9:12   ` Sergio Paracuellos
2024-04-12 21:33 ` Bjorn Helgaas
2024-04-13 10:10   ` Sergio Paracuellos
2024-05-17 11:29 ` Krzysztof Wilczyński

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).