Skip to contentSkip to conversation

misc: pci_endpoint_test: Fix potential truncation in pci_endpoint_test_probe()

PATCH Applied Niklas Cassel 3 participants 5 messages Jan 23, 2025 – Feb 14, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: pci_endpoint_test: Fix potential truncation in pci_endpoint_test_probe()

Increase the size of the string buffer to avoid potential truncation in pci_endpoint_test_probe().

This fixes the following build warning when compiling with W=1:

drivers/misc/pci_endpoint_test.c:29:49: note: directive argument in the range [0, 2147483647]

   29 | #define DRV_MODULE_NAME                         "pci-endpoint-test"
      |                                                 ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:38: note: in expansion of macro ‘DRV_MODULE_NAME’
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |                                      ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:9: note: ‘snprintf’ output between 20 and 29 bytes into a destination of size 24
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
index 8e48a15100f1..b0db94161d31 100644
@@ -912,7 +912,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 {
 	int ret;
 	int id;
-	char name[24];
+	char name[29];
 	enum pci_barno bar;
 	void __iomem *base;
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Niklas Cassel

Increase the size of the string buffer to avoid potential truncation in pci_endpoint_test_probe().

This fixes the following build warning when compiling with W=1:

drivers/misc/pci_endpoint_test.c:29:49: note: directive argument in the range [0, 2147483647]

   29 | #define DRV_MODULE_NAME                         "pci-endpoint-test"
      |                                                 ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:38: note: in expansion of macro ‘DRV_MODULE_NAME’
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |                                      ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:9: note: ‘snprintf’ output between 20 and 29 bytes into a destination of size 24
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 2 lines

---

Quoted 19 lines
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -2
index 8e48a15100f1..b0db94161d31 100644
@@ -912,7 +912,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 {
 	int ret;
 	int id;
-	char name[24];
+	char name[29];
 	enum pci_barno bar;
 	void __iomem *base;
 	struct device *dev = &pdev->dev;
--

2.48.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Niklas Cassel
Quoted 15 lines · Niklas Cassel

Increase the size of the string buffer to avoid potential truncation in pci_endpoint_test_probe().

This fixes the following build warning when compiling with W=1:

drivers/misc/pci_endpoint_test.c:29:49: note: directive argument in the range [0, 2147483647]

   29 | #define DRV_MODULE_NAME                         "pci-endpoint-test"
      |                                                 ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:38: note: in expansion of macro ‘DRV_MODULE_NAME’
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |                                      ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:9: note: ‘snprintf’ output between 20 and 29 bytes into a destination of size 24
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 1 line

- Mani

Quoted 20 lines
---
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
index 8e48a15100f1..b0db94161d31 100644
@@ -912,7 +912,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 {
 	int ret;
 	int id;
-	char name[24];
+	char name[29];
 	enum pci_barno bar;
 	void __iomem *base;
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.48.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
In reply to Niklas Cassel
Quoted 36 lines · Niklas Cassel

Increase the size of the string buffer to avoid potential truncation in pci_endpoint_test_probe().

This fixes the following build warning when compiling with W=1:

drivers/misc/pci_endpoint_test.c:29:49: note: directive argument in the range [0, 2147483647]

   29 | #define DRV_MODULE_NAME                         "pci-endpoint-test"
      |                                                 ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:38: note: in expansion of macro ‘DRV_MODULE_NAME’
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |                                      ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:9: note: ‘snprintf’ output between 20 and 29 bytes into a destination of size 24
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
index 8e48a15100f1..b0db94161d31 100644
@@ -912,7 +912,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 {
 	int ret;
 	int id;
-	char name[24];
+	char name[29];
 	enum pci_barno bar;
 	void __iomem *base;
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.48.1

Gentle ping.

Kind regards,
Niklas

#4 lore raw
In reply to Niklas Cassel
Quoted 15 lines · Niklas Cassel

Increase the size of the string buffer to avoid potential truncation in pci_endpoint_test_probe().

This fixes the following build warning when compiling with W=1:

drivers/misc/pci_endpoint_test.c:29:49: note: directive argument in the range [0, 2147483647]

   29 | #define DRV_MODULE_NAME                         "pci-endpoint-test"
      |                                                 ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:38: note: in expansion of macro ‘DRV_MODULE_NAME’
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |                                      ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:998:9: note: ‘snprintf’ output between 20 and 29 bytes into a destination of size 24
  998 |         snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 1 line

Applied to pci/endpoint!

- Mani

Quoted 20 lines
---
 drivers/misc/pci_endpoint_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
index 8e48a15100f1..b0db94161d31 100644
@@ -912,7 +912,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 {
 	int ret;
 	int id;
-	char name[24];
+	char name[29];
 	enum pci_barno bar;
 	void __iomem *base;
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.48.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்