diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-04-13 15:48:28 -0400 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2017-04-18 05:50:05 -0400 |
commit | c821ee6d2bb4cfc9991bf285f53103cde9d3593a (patch) | |
tree | 6cbf86111841e1a988f5789dce28ebd2ebb70998 | |
parent | 5ad59bf0960b807f01cb6ef8c54f68b3476a1546 (diff) |
drm/i915/gvt: fix a bounds check in ring_id_to_context_switch_event()
There are two bugs here. The && should be || and the > is off by one so
it should be >= ARRAY_SIZE().
Fixes: 8453d674ae7e ("drm/i915/gvt: vGPU execlist virtualization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/gvt/execlist.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c index d077ed97970f..dc9aef3e92d4 100644 --- a/drivers/gpu/drm/i915/gvt/execlist.c +++ b/drivers/gpu/drm/i915/gvt/execlist.c | |||
@@ -56,8 +56,8 @@ static int context_switch_events[] = { | |||
56 | 56 | ||
57 | static int ring_id_to_context_switch_event(int ring_id) | 57 | static int ring_id_to_context_switch_event(int ring_id) |
58 | { | 58 | { |
59 | if (WARN_ON(ring_id < RCS && ring_id > | 59 | if (WARN_ON(ring_id < RCS || |
60 | ARRAY_SIZE(context_switch_events))) | 60 | ring_id >= ARRAY_SIZE(context_switch_events))) |
61 | return -EINVAL; | 61 | return -EINVAL; |
62 | 62 | ||
63 | return context_switch_events[ring_id]; | 63 | return context_switch_events[ring_id]; |