Re: [PATCH] virtio: vdpa: fix snprintf size argument in snet_vdpa driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 20, 2022 at 11:20 PM Alvaro Karsz
<alvaro.karsz@xxxxxxxxxxxxx> wrote:
>
> 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 alvaro.karsz@xxxxxxxxxxxxx
>
> Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Signed-off-by: Alvaro Karsz <alvaro.karsz@xxxxxxxxxxxxx>

Thanks for the fix!
Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>

> ---
>  drivers/vdpa/solidrun/snet_main.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c
> index d438a89b359..9ceacf96de0 100644
> --- a/drivers/vdpa/solidrun/snet_main.c
> +++ b/drivers/vdpa/solidrun/snet_main.c
> @@ -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
>


-- 
Thanks,
~Nick Desaulniers
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux