diff options
| author | Aleksei Gimbitskii <aleksei.gimbitskii@intel.com> | 2019-04-23 08:04:13 -0400 |
|---|---|---|
| committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2019-04-25 03:36:29 -0400 |
| commit | 930c8dfea4b8f320bd7f6a3e5e721ac20e444e03 (patch) | |
| tree | 7b506968128d833bdcfcba2c10a2a22655ba6c51 | |
| parent | 4feeea1d8d7713c5838d99c1fdfcc2e90c0f977d (diff) | |
drm/i915/gvt: Check if get_next_pt_type() always returns a valid value
According to gtt_type_table[] function get_next_pt_type() may returns
GTT_TYPE_INVALID in some cases. To prevent driver to try to create memory
page with invalid data type, additional check is added.
Signed-off-by: Aleksei Gimbitskii <aleksei.gimbitskii@intel.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Colin Xu <colin.xu@intel.com>
Reviewed-by: Colin Xu <colin.xu@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
| -rw-r--r-- | drivers/gpu/drm/i915/gvt/gtt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index 7600416db908..08c74e65836b 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c | |||
| @@ -1076,6 +1076,9 @@ static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry( | |||
| 1076 | } else { | 1076 | } else { |
| 1077 | int type = get_next_pt_type(we->type); | 1077 | int type = get_next_pt_type(we->type); |
| 1078 | 1078 | ||
| 1079 | if (!gtt_type_is_pt(type)) | ||
| 1080 | goto err; | ||
| 1081 | |||
| 1079 | spt = ppgtt_alloc_spt_gfn(vgpu, type, ops->get_pfn(we), ips); | 1082 | spt = ppgtt_alloc_spt_gfn(vgpu, type, ops->get_pfn(we), ips); |
| 1080 | if (IS_ERR(spt)) { | 1083 | if (IS_ERR(spt)) { |
| 1081 | ret = PTR_ERR(spt); | 1084 | ret = PTR_ERR(spt); |
