On Fri, Sep 12, 2025 at 11:55:29AM -0700, Alex Mastro wrote:
> On Mon, Aug 04, 2025 at 04:00:45PM +0300, Leon Romanovsky wrote:
> > +static void dma_ranges_to_p2p_phys(struct vfio_pci_dma_buf *priv,
> > +                              struct vfio_device_feature_dma_buf *dma_buf,
> > +                              struct vfio_region_dma_range *dma_ranges)
> > +{
> > +   struct pci_dev *pdev = priv->vdev->pdev;
> > +   phys_addr_t pci_start;
> > +   int i;
> > +
> > +   pci_start = pci_resource_start(pdev, dma_buf->region_index);
> > +   for (i = 0; i < dma_buf->nr_ranges; i++) {
> > +           priv->phys_vec[i].len = dma_ranges[i].length;
> > +           priv->phys_vec[i].paddr += pci_start + dma_ranges[i].offset;
> 
> Is the intent really to += paddr? I would have expected a plain assignment.

In this specific case, there is no difference, because phys_vec is
initialized to 0, but It needs to be "=" and not "+=".

> 
> > +           priv->size += priv->phys_vec[i].len;
> > +   }
> > +   priv->nr_ranges = dma_buf->nr_ranges;
> > +}
> 
> ...
> 
> > +   priv->phys_vec = kcalloc(get_dma_buf.nr_ranges, sizeof(*priv->phys_vec),
> > +                            GFP_KERNEL);
> > +   if (!priv->phys_vec) {
> > +           ret = -ENOMEM;
> > +           goto err_free_priv;
> > +   }
> > +
> > +   priv->vdev = vdev;
> > +   dma_ranges_to_p2p_phys(priv, &get_dma_buf, dma_ranges);
> 

Reply via email to