drm/i915: Avoid memory leak with more than 16 workarounds on a list
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 13 Nov 2020 13:25:10 +0000 (13:25 +0000)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Mon, 16 Nov 2020 10:54:47 +0000 (10:54 +0000)
I forgot to free the old list when growing past 16 entries.

Luckily, as much as I checked, none of the current platforms has more than
16 workarounds on a single list.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: 452420d22d5b ("drm/i915: Fuse per-context workaround handling with the common framework")
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20201113132510.2298483-1-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/gt/intel_workarounds.c

index fed9503..adc9a8e 100644 (file)
@@ -131,8 +131,10 @@ static void _wa_add(struct i915_wa_list *wal, const struct i915_wa *wa)
                        return;
                }
 
-               if (wal->list)
+               if (wal->list) {
                        memcpy(list, wal->list, sizeof(*wa) * wal->count);
+                       kfree(wal->list);
+               }
 
                wal->list = list;
        }