]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/gt: Use kmemdup_array instead of kmemdup for multiple allocation
authorYu Jiaoliang <yujiaoliang@vivo.com>
Wed, 21 Aug 2024 14:40:36 +0000 (16:40 +0200)
committerAndi Shyti <andi.shyti@linux.intel.com>
Fri, 23 Aug 2024 23:13:08 +0000 (01:13 +0200)
Let the kememdup_array() take care about multiplication and possible
overflows.

v2:
- Change subject
- Leave one blank line between the commit log and the tag section
- Fix code alignment issue

v3:
- Fix code alignment
- Apply the patch on a clean drm-tip

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240821144036.343556-1-andi.shyti@linux.intel.com
drivers/gpu/drm/i915/gt/intel_workarounds.c

index bfe6d8fc820fec95c1562ec0f143cd1a03529ad0..baa609bdf7cb4fe8db3b11da6d066c9282e3f758 100644 (file)
@@ -111,9 +111,8 @@ static void wa_init_finish(struct i915_wa_list *wal)
 {
        /* Trim unused entries. */
        if (!IS_ALIGNED(wal->count, WA_LIST_CHUNK)) {
-               struct i915_wa *list = kmemdup(wal->list,
-                                              wal->count * sizeof(*list),
-                                              GFP_KERNEL);
+               struct i915_wa *list = kmemdup_array(wal->list, wal->count,
+                                                    sizeof(*list), GFP_KERNEL);
 
                if (list) {
                        kfree(wal->list);