summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915
diff options
context:
space:
mode:
authorJike Song2016-12-16 03:51:04 +0100
committerZhenyu Wang2016-12-26 02:45:29 +0100
commitbfeca3e5716a16b95a1fb7104e477ca3bd5ed59e (patch)
tree154723a3220195b1484c5eb186b50e9637d1a270 /drivers/gpu/drm/i915
parentdrm/i915/gvt: reset the GGTT entry when vGPU created (diff)
downloadkernel-qcow2-linux-bfeca3e5716a16b95a1fb7104e477ca3bd5ed59e.tar.gz
kernel-qcow2-linux-bfeca3e5716a16b95a1fb7104e477ca3bd5ed59e.tar.xz
kernel-qcow2-linux-bfeca3e5716a16b95a1fb7104e477ca3bd5ed59e.zip
drm/i915/gvt/kvmgt: dereference the pointer within lock
Though there is no issue exposed yet, it's possible that another thread releases the entry while our trying to deref it out of the lock. Fit it by moving the dereference within lock. Signed-off-by: Jike Song <jike.song@intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4dd6722a7339..4ba196796846 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -114,12 +114,15 @@ out:
static kvm_pfn_t gvt_cache_find(struct intel_vgpu *vgpu, gfn_t gfn)
{
struct gvt_dma *entry;
+ kvm_pfn_t pfn;
mutex_lock(&vgpu->vdev.cache_lock);
+
entry = __gvt_cache_find(vgpu, gfn);
- mutex_unlock(&vgpu->vdev.cache_lock);
+ pfn = (entry == NULL) ? 0 : entry->pfn;
- return entry == NULL ? 0 : entry->pfn;
+ mutex_unlock(&vgpu->vdev.cache_lock);
+ return pfn;
}
static void gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn, kvm_pfn_t pfn)