Skip to content

Commit b18b6bd

Browse files
Ben Widawskydanvet
authored andcommitted
drm/i915/bdw: Free PPGTT struct
GEN8 never freed the PPGTT struct. As GEN8 doesn't use full PPGTT, the leak is small and only found on a module reload. ie. I don't think this needs to go to stable. v2: The very naive, kfree in gen8 ppgtt cleanup, is subject to a double free on PPGTT initialization failure. (Spotted by Imre). Instead this patch pulls the ppgtt struct freeing out of the cleanup and leaves it to the allocators/callers or the one doing the last kref_put as in standard convention Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 321f2ad commit b18b6bd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/gpu/drm/i915/i915_gem_context.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@
9999
static int do_switch(struct intel_ring_buffer *ring,
100100
struct i915_hw_context *to);
101101

102-
static void ppgtt_release(struct kref *kref)
102+
static void do_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt)
103103
{
104-
struct i915_hw_ppgtt *ppgtt = container_of(kref, struct i915_hw_ppgtt, ref);
105104
struct drm_device *dev = ppgtt->base.dev;
106105
struct drm_i915_private *dev_priv = dev->dev_private;
107106
struct i915_address_space *vm = &ppgtt->base;
@@ -135,6 +134,15 @@ static void ppgtt_release(struct kref *kref)
135134
ppgtt->base.cleanup(&ppgtt->base);
136135
}
137136

137+
static void ppgtt_release(struct kref *kref)
138+
{
139+
struct i915_hw_ppgtt *ppgtt =
140+
container_of(kref, struct i915_hw_ppgtt, ref);
141+
142+
do_ppgtt_cleanup(ppgtt);
143+
kfree(ppgtt);
144+
}
145+
138146
static size_t get_context_alignment(struct drm_device *dev)
139147
{
140148
if (IS_GEN6(dev))

drivers/gpu/drm/i915/i915_gem_gtt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)
859859
for (i = 0; i < ppgtt->num_pd_entries; i++)
860860
__free_page(ppgtt->pt_pages[i]);
861861
kfree(ppgtt->pt_pages);
862-
kfree(ppgtt);
863862
}
864863

865864
static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)

0 commit comments

Comments
 (0)