virtio: vdpa: fix snprintf size argument in snet_vdpa driver
Subsystems (2)
Alvaro Karsz
reviewerPATCH 1/1 virtio: vdpa: fix snprintf size argument in snet_vdpa driver
The buffer size and the size passed to snprintf don't match, causing clang warnings.
This patch increases a little bit the size of the buffer, and uses sizeof() to get the buffer size.
This patch should be applied on top of the following patch:
virtio: vdpa: new SolidNET DPU driver,
by Alvaro Karsz [email protected]
--- drivers/vdpa/solidrun/snet_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/vdpa/solidrun/snet_main.c +4 -4
@@ -540,7 +540,7 @@ static const struct vdpa_config_ops snet_config_ops = {static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet) { -char name[25 ]; +char name[50 ];int ret, i, mask =0 ;/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0.
@@ -558,7 +558,7 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)return -ENODEV ; } -snprintf (name,SNET_NAME_SIZE ,"psnet[%s]-bars" ,pci_name (pdev)); +snprintf (name,sizeof (name),"psnet[%s]-bars" ,pci_name (pdev)); ret =pcim_iomap_regions (pdev, mask, name);if (ret) {SNET_ERR (pdev,"Failed to request and map PCI BARs\n" );
@@ -575,10 +575,10 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)static int snet_open_vf_bar (struct pci_dev *pdev,struct snet *snet) { -char name[20 ]; +char name[50 ];int ret; -snprintf (name,SNET_NAME_SIZE ,"snet[%s]-bar" ,pci_name (pdev)); +snprintf (name,sizeof (name),"snet[%s]-bar" ,pci_name (pdev));/* Request and map BAR */ ret =pcim_iomap_regions (pdev,BIT (snet->psnet->cfg.vf_bar), name);if (ret) {
Signature · 6 lines
2.32.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 7 lines · Alvaro Karsz
The buffer size and the size passed to snprintf don't match, causing clang warnings.
This patch increases a little bit the size of the buffer, and uses
sizeof()to get the buffer size.
Quoted 7 lines
This patch should be applied on top of the following patch:
virtio: vdpa: new SolidNET DPU driver,
by Alvaro Karsz [email protected]Reported-by Nathan Chancellor <[email protected]>Signed-off-by Alvaro Karsz <[email protected]>
Thanks for the fix!
Quoted 42 lines
--- drivers/vdpa/solidrun/snet_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/vdpa/solidrun/snet_main.c +4
-5@@ -540,7 +540,7 @@ static const struct vdpa_config_ops snet_config_ops = {static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet) { -char name[25 ]; +char name[50 ];int ret, i, mask =0 ;/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. @@ -558,7 +558,7 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)return -ENODEV ; } -snprintf (name,SNET_NAME_SIZE ,"psnet[%s]-bars" ,pci_name (pdev)); +snprintf (name,sizeof (name),"psnet[%s]-bars" ,pci_name (pdev)); ret =pcim_iomap_regions (pdev, mask, name);if (ret) {SNET_ERR (pdev,"Failed to request and map PCI BARs\n" );@@ -575,10 +575,10 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)static int snet_open_vf_bar (struct pci_dev *pdev,struct snet *snet) { -char name[20 ]; +char name[50 ];int ret; -snprintf (name,SNET_NAME_SIZE ,"snet[%s]-bar" ,pci_name (pdev)); +snprintf (name,sizeof (name),"snet[%s]-bar" ,pci_name (pdev));/* Request and map BAR */ ret =pcim_iomap_regions (pdev,BIT (snet->psnet->cfg.vf_bar), name);if (ret) { --2.32.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 7 lines · Alvaro Karsz
The buffer size and the size passed to snprintf don't match, causing clang warnings.
This patch increases a little bit the size of the buffer, and uses
sizeof()to get the buffer size.
Quoted 7 lines
This patch should be applied on top of the following patch:
virtio: vdpa: new SolidNET DPU driver,
by Alvaro Karsz [email protected]Reported-by Nathan Chancellor <[email protected]>Signed-off-by Alvaro Karsz <[email protected]>
Thanks
Quoted 40 lines
--- drivers/vdpa/solidrun/snet_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/vdpa/solidrun/snet_main.c +4
-5@@ -540,7 +540,7 @@ static const struct vdpa_config_ops snet_config_ops = {static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet) { -char name[25 ]; +char name[50 ];int ret, i, mask =0 ;/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. @@ -558,7 +558,7 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)return -ENODEV ; } -snprintf (name,SNET_NAME_SIZE ,"psnet[%s]-bars" ,pci_name (pdev)); +snprintf (name,sizeof (name),"psnet[%s]-bars" ,pci_name (pdev)); ret =pcim_iomap_regions (pdev, mask, name);if (ret) {SNET_ERR (pdev,"Failed to request and map PCI BARs\n" );@@ -575,10 +575,10 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)static int snet_open_vf_bar (struct pci_dev *pdev,struct snet *snet) { -char name[20 ]; +char name[50 ];int ret; -snprintf (name,SNET_NAME_SIZE ,"snet[%s]-bar" ,pci_name (pdev)); +snprintf (name,sizeof (name),"snet[%s]-bar" ,pci_name (pdev));/* Request and map BAR */ ret =pcim_iomap_regions (pdev,BIT (snet->psnet->cfg.vf_bar), name);if (ret) { --
Quoted 2 lines
2.32.0
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Alvaro Karsz
reviewerHi Michael,
This patch was merged into:
[PATCH v7] virtio: vdpa: new SolidNET DPU driver.
So it can be ignored.
Thank you.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization