* [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify()
@ 2025-01-04 0:21 Niklas Cassel
2025-01-04 4:29 ` Manivannan Sadhasivam
2025-01-15 11:24 ` Krzysztof Wilczyński
0 siblings, 2 replies; 5+ messages in thread
From: Niklas Cassel @ 2025-01-04 0:21 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: Damien Le Moal, Niklas Cassel, linux-pci
Increase the size of the string buffer to avoid potential truncation in
dw_pcie_edma_irq_verify().
This fixes the following build warning when compiling with W=1:
drivers/pci/controller/dwc/pcie-designware.c: In function ‘dw_pcie_edma_detect’:
drivers/pci/controller/dwc/pcie-designware.c:989:50: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
989 | snprintf(name, sizeof(name), "dma%d", pci->edma.nr_irqs);
| ^~
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
Changes since v2:
-Simply increase the size of the string buffer instead of chaning the
print format specifier.
drivers/pci/controller/dwc/pcie-designware.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 3c683b6119c3..145e7f579072 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -971,7 +971,7 @@ static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
{
struct platform_device *pdev = to_platform_device(pci->dev);
u16 ch_cnt = pci->edma.ll_wr_cnt + pci->edma.ll_rd_cnt;
- char name[6];
+ char name[15];
int ret;
if (pci->edma.nr_irqs == 1)
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify()
2025-01-04 0:21 [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify() Niklas Cassel
@ 2025-01-04 4:29 ` Manivannan Sadhasivam
2025-01-04 4:43 ` Niklas Cassel
2025-01-15 11:24 ` Krzysztof Wilczyński
1 sibling, 1 reply; 5+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-04 4:29 UTC (permalink / raw)
To: Niklas Cassel
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
Rob Herring, Bjorn Helgaas, Damien Le Moal, linux-pci
On Sat, Jan 04, 2025 at 01:21:20AM +0100, Niklas Cassel wrote:
> Increase the size of the string buffer to avoid potential truncation in
> dw_pcie_edma_irq_verify().
>
> This fixes the following build warning when compiling with W=1:
>
> drivers/pci/controller/dwc/pcie-designware.c: In function ‘dw_pcie_edma_detect’:
> drivers/pci/controller/dwc/pcie-designware.c:989:50: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
> 989 | snprintf(name, sizeof(name), "dma%d", pci->edma.nr_irqs);
> | ^~
>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> Changes since v2:
> -Simply increase the size of the string buffer instead of chaning the
> print format specifier.
>
> drivers/pci/controller/dwc/pcie-designware.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 3c683b6119c3..145e7f579072 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -971,7 +971,7 @@ static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
> {
> struct platform_device *pdev = to_platform_device(pci->dev);
> u16 ch_cnt = pci->edma.ll_wr_cnt + pci->edma.ll_rd_cnt;
> - char name[6];
> + char name[15];
Isn't 14 big enough to hold INT_MAX + 'dma'? Not a big deal, but asking just for
the sake of correctness.
- Mani
> int ret;
>
> if (pci->edma.nr_irqs == 1)
> --
> 2.47.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify()
2025-01-04 4:29 ` Manivannan Sadhasivam
@ 2025-01-04 4:43 ` Niklas Cassel
2025-01-04 8:46 ` Manivannan Sadhasivam
0 siblings, 1 reply; 5+ messages in thread
From: Niklas Cassel @ 2025-01-04 4:43 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
Rob Herring, Bjorn Helgaas, Damien Le Moal, linux-pci
On Sat, Jan 04, 2025 at 09:59:01AM +0530, Manivannan Sadhasivam wrote:
> On Sat, Jan 04, 2025 at 01:21:20AM +0100, Niklas Cassel wrote:
> > Increase the size of the string buffer to avoid potential truncation in
> > dw_pcie_edma_irq_verify().
> >
> > This fixes the following build warning when compiling with W=1:
> >
> > drivers/pci/controller/dwc/pcie-designware.c: In function ‘dw_pcie_edma_detect’:
> > drivers/pci/controller/dwc/pcie-designware.c:989:50: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
> > 989 | snprintf(name, sizeof(name), "dma%d", pci->edma.nr_irqs);
> > | ^~
> >
> > Signed-off-by: Niklas Cassel <cassel@kernel.org>
> > ---
> > Changes since v2:
> > -Simply increase the size of the string buffer instead of chaning the
> > print format specifier.
> >
> > drivers/pci/controller/dwc/pcie-designware.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > index 3c683b6119c3..145e7f579072 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -971,7 +971,7 @@ static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
> > {
> > struct platform_device *pdev = to_platform_device(pci->dev);
> > u16 ch_cnt = pci->edma.ll_wr_cnt + pci->edma.ll_rd_cnt;
> > - char name[6];
> > + char name[15];
>
> Isn't 14 big enough to hold INT_MAX + 'dma'? Not a big deal, but asking just for
> the sake of correctness.
We need to be able to hold INT_MIN which is "-2147483648" 11 chars/bytes
+ "dma" 3 chars/bytes + terminating null byte (1 char/byte) = 15.
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify()
2025-01-04 4:43 ` Niklas Cassel
@ 2025-01-04 8:46 ` Manivannan Sadhasivam
0 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-04 8:46 UTC (permalink / raw)
To: Niklas Cassel
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
Rob Herring, Bjorn Helgaas, Damien Le Moal, linux-pci
On Sat, Jan 04, 2025 at 05:43:41AM +0100, Niklas Cassel wrote:
> On Sat, Jan 04, 2025 at 09:59:01AM +0530, Manivannan Sadhasivam wrote:
> > On Sat, Jan 04, 2025 at 01:21:20AM +0100, Niklas Cassel wrote:
> > > Increase the size of the string buffer to avoid potential truncation in
> > > dw_pcie_edma_irq_verify().
> > >
> > > This fixes the following build warning when compiling with W=1:
> > >
> > > drivers/pci/controller/dwc/pcie-designware.c: In function ‘dw_pcie_edma_detect’:
> > > drivers/pci/controller/dwc/pcie-designware.c:989:50: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
> > > 989 | snprintf(name, sizeof(name), "dma%d", pci->edma.nr_irqs);
> > > | ^~
> > >
> > > Signed-off-by: Niklas Cassel <cassel@kernel.org>
> > > ---
> > > Changes since v2:
> > > -Simply increase the size of the string buffer instead of chaning the
> > > print format specifier.
> > >
> > > drivers/pci/controller/dwc/pcie-designware.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 3c683b6119c3..145e7f579072 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -971,7 +971,7 @@ static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
> > > {
> > > struct platform_device *pdev = to_platform_device(pci->dev);
> > > u16 ch_cnt = pci->edma.ll_wr_cnt + pci->edma.ll_rd_cnt;
> > > - char name[6];
> > > + char name[15];
> >
> > Isn't 14 big enough to hold INT_MAX + 'dma'? Not a big deal, but asking just for
> > the sake of correctness.
>
> We need to be able to hold INT_MIN which is "-2147483648" 11 chars/bytes
> + "dma" 3 chars/bytes + terminating null byte (1 char/byte) = 15.
>
Ah, brain fade (missing the null byte termination).
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify()
2025-01-04 0:21 [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify() Niklas Cassel
2025-01-04 4:29 ` Manivannan Sadhasivam
@ 2025-01-15 11:24 ` Krzysztof Wilczyński
1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Wilczyński @ 2025-01-15 11:24 UTC (permalink / raw)
To: Niklas Cassel
Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi, Rob Herring,
Bjorn Helgaas, Damien Le Moal, linux-pci
Hello,
> Increase the size of the string buffer to avoid potential truncation in
> dw_pcie_edma_irq_verify().
>
> This fixes the following build warning when compiling with W=1:
>
> drivers/pci/controller/dwc/pcie-designware.c: In function ‘dw_pcie_edma_detect’:
> drivers/pci/controller/dwc/pcie-designware.c:989:50: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
> 989 | snprintf(name, sizeof(name), "dma%d", pci->edma.nr_irqs);
> | ^~
Applied to controller/dwc for v6.14, thank you!
Krzysztof
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-15 11:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-04 0:21 [PATCH v3] PCI: dwc: Fix potential truncation in dw_pcie_edma_irq_verify() Niklas Cassel
2025-01-04 4:29 ` Manivannan Sadhasivam
2025-01-04 4:43 ` Niklas Cassel
2025-01-04 8:46 ` Manivannan Sadhasivam
2025-01-15 11:24 ` 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