drm/i915: Make i915_pipe_crc_read() oops proof
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 9 Dec 2014 19:28:32 +0000 (21:28 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 10 Dec 2014 16:47:26 +0000 (17:47 +0100)
commit9ad6d99f189c274b42bedd6efc2b31a17ce733a7
tree1869fa7c8840329713082928bf4a83969504b963
parent3cf54b34dafe800d9522b93249b6f4c1bfb50de2
drm/i915: Make i915_pipe_crc_read() oops proof

Currently i915_pipe_crc_read() will drop pipe_crc->lock for the entire
duration of the copy_to_user() loop, which means it'll access
pipe_crc->entries without any protection. If another thread sneaks in
and frees pipe_crc->entries the code will oops.

Reorganize the code to hold the lock around everything except
copy_to_user(). After the copy the lock is reacquired and the the number
of available entries is rechecked.

Since this is a debug feature simplify the error handling a bit by
consuming the crc entry even if copy_to_user() would fail.

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