On Wed, 13 Nov 2024 13:51:58 +0200
Yishai Hadas <yish...@nvidia.com> wrote:
> diff --git a/drivers/vfio/pci/virtio/migrate.c 
> b/drivers/vfio/pci/virtio/migrate.c
> new file mode 100644
> index 000000000000..a0ce3ec2c734
> --- /dev/null
> +++ b/drivers/vfio/pci/virtio/migrate.c
...
> +static int virtiovf_add_migration_pages(struct virtiovf_data_buffer *buf,
> +                                     unsigned int npages)
> +{
> +     unsigned int to_alloc = npages;
> +     struct page **page_list;
> +     unsigned long filled;
> +     unsigned int to_fill;
> +     int ret;
> +     int i;
> +
> +     to_fill = min_t(unsigned int, npages, PAGE_SIZE / sizeof(*page_list));
> +     page_list = kvzalloc(to_fill * sizeof(*page_list), GFP_KERNEL_ACCOUNT);

checkpatch spots the following:

WARNING: Prefer kvcalloc over kvzalloc with multiply
#416: FILE: drivers/vfio/pci/virtio/migrate.c:71:
+       page_list = kvzalloc(to_fill * sizeof(*page_list), GFP_KERNEL_ACCOUNT);


With your approval I'll update with the following on commit:

diff --git a/drivers/vfio/pci/virtio/migrate.c 
b/drivers/vfio/pci/virtio/migrate.c
index a0ce3ec2c734..4fdf6ca17a3a 100644
--- a/drivers/vfio/pci/virtio/migrate.c
+++ b/drivers/vfio/pci/virtio/migrate.c
@@ -68,7 +68,7 @@ static int virtiovf_add_migration_pages(struct 
virtiovf_data_buffer *buf,
        int i;
 
        to_fill = min_t(unsigned int, npages, PAGE_SIZE / sizeof(*page_list));
-       page_list = kvzalloc(to_fill * sizeof(*page_list), GFP_KERNEL_ACCOUNT);
+       page_list = kvcalloc(to_fill, sizeof(*page_list), GFP_KERNEL_ACCOUNT);
        if (!page_list)
                return -ENOMEM;
 
Thanks,
Alex


Reply via email to