]> git.itanic.dy.fi Git - linux-stable/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 11:09:56 +0000 (13:09 +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 80e90fdef291d5b8cdcf7d08c6e319150fcf631b..08da993df1480edacf96c2eee9eacdc14ebc3a9c 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;