amdkfd: use calloc instead of kzalloc to avoid integer overflow
authorjsg <jsg@openbsd.org>
Mon, 15 Apr 2024 01:40:36 +0000 (01:40 +0000)
committerjsg <jsg@openbsd.org>
Mon, 15 Apr 2024 01:40:36 +0000 (01:40 +0000)
From Dave Airlie
315eb3c2df7e4cb18e3eacfa18a53a46f2bf0ef7 in linux-6.6.y/6.6.27
3b0daecfeac0103aba8b293df07a0cbaf8b43f29 in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_chardev.c

index 29594b0..4fbdc94 100644 (file)
@@ -778,8 +778,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;