drm/i915: Protect against leaks in pipe_crc_set_source
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 10 Dec 2014 10:00:29 +0000 (11:00 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 10 Dec 2014 16:47:27 +0000 (17:47 +0100)
Stupid userspace (there is no evil userspace in debugfs by assumption)
might provoke a leak since we allocate the new array without holding
any locks. Drop in an unconditional kfree to deal with this - kfree
can handle NULL.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
drivers/gpu/drm/i915/i915_debugfs.c

index 252b0b2b514cad61335c5813bd570fe9b795f0bf..165a38f360098450bbc96e2e1d5d078635e982c3 100644 (file)
@@ -3433,6 +3433,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
                hsw_disable_ips(crtc);
 
                spin_lock_irq(&pipe_crc->lock);
+               kfree(pipe_crc->entries);
                pipe_crc->entries = entries;
                pipe_crc->head = 0;
                pipe_crc->tail = 0;