]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
amdkfd: use calloc instead of kzalloc to avoid integer overflow
authorDave Airlie <airlied@redhat.com>
Thu, 11 Apr 2024 20:11:25 +0000 (06:11 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 10:50:17 +0000 (12:50 +0200)
commit 3b0daecfeac0103aba8b293df07a0cbaf8b43f29 upstream.

This uses calloc instead of doing the multiplication which might
overflow.

Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 297b36c26a05c819634f9cdeb9426aa243f76fe4..840dfe8524e4d8f35216cb554e6c438ed9e7a161 100644 (file)
@@ -923,8 +923,8 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp,
         * nodes, but not more than args->num_of_nodes as that is
         * the amount of memory allocated by user
         */
-       pa = kzalloc((sizeof(struct kfd_process_device_apertures) *
-                               args->num_of_nodes), GFP_KERNEL);
+       pa = kcalloc(args->num_of_nodes, sizeof(struct kfd_process_device_apertures),
+                    GFP_KERNEL);
        if (!pa)
                return -ENOMEM;