drm/i915/gvt: don't dereference 'workload' before null checking it
PATCH 1/1 drm/i915/gvt: don't dereference 'workload' before null checking it
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
--- drivers/gpu/drm/i915/gvt/scheduler.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/scheduler.c +7 -3
@@ -60,9 +60,9 @@ static void set_context_pdp_root_pointer(static void sr_oa_regs (struct intel_vgpu_workload *workload,u32 *reg_state,bool save) { -struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv; -u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; -u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +struct drm_i915_private *dev_priv; +u32 ctx_oactxctrl; +u32 ctx_flexeu0;int i =0 ;u32 flex_mmio[] = {i915_mmio_reg_offset (EU_PERF_CNTL0 ),
@@ -77,6 +77,10 @@ static void sr_oa_regs(struct intel_vgpu_workload *workload,if (!workload || !reg_state || workload->ring_id !=RCS )return ; + dev_priv = workload->vgpu->gvt->dev_priv; + ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; + ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +if (save) { workload->oactxctrl = reg_state[ctx_oactxctrl +1 ];
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Colin King
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
Maybe true, but is it possible for workload to be null? Maybe the null test should be removed instead.
Quoted 24 lines
Fixes fa3dd623e559 ("drm/i915/gvt: keep oa config in shadow ctx")Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/i915/gvt/scheduler.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gvt/scheduler.c +3
-3@@ -60,9 +60,9 @@ static void set_context_pdp_root_pointer(static void sr_oa_regs (struct intel_vgpu_workload *workload,u32 *reg_state,bool save) { -struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv; -u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; -u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +struct drm_i915_private *dev_priv; +u32 ctx_oactxctrl; +u32 ctx_flexeu0;int i =0 ;u32 flex_mmio[] = {i915_mmio_reg_offset (EU_PERF_CNTL0 ),
drivers/gpu/drm/i915/gvt/scheduler.c static void sr_oa_regs(struct intel_vgpu_workload *workload, · line 86
Quoted 10 lines
drivers/gpu/drm/i915/gvt/scheduler.c +4
-0@@ -77,6 +77,10 @@ static void sr_oa_regs(struct intel_vgpu_workload *workload,if (!workload || !reg_state || workload->ring_id !=RCS )return ; + dev_priv = workload->vgpu->gvt->dev_priv; + ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; + ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +if (save) { workload->oactxctrl = reg_state[ctx_oactxctrl +1 ];
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Joe Perches
Quoted 6 lines · Colin King
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Quoted 6 lines
Quoted 1 line
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
Maybe true, but is it possible for workload to be null? Maybe the null test should be removed instead.
From what I understand from the static analysis, there may be a
potential for workload to be null, I couldn't rule it out so I went with the more paranoid stance of keeping the null check in.
Quoted 35 lines
Quoted 35 lines
Fixes fa3dd623e559 ("drm/i915/gvt: keep oa config in shadow ctx")Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/i915/gvt/scheduler.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gvt/scheduler.c +7
-3@@ -60,9 +60,9 @@ static void set_context_pdp_root_pointer(static void sr_oa_regs (struct intel_vgpu_workload *workload,u32 *reg_state,bool save) { -struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv; -u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; -u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +struct drm_i915_private *dev_priv; +u32 ctx_oactxctrl; +u32 ctx_flexeu0;int i =0 ;u32 flex_mmio[] = {i915_mmio_reg_offset (EU_PERF_CNTL0 ),@@ -77,6 +77,10 @@ static void sr_oa_regs(struct intel_vgpu_workload *workload,if (!workload || !reg_state || workload->ring_id !=RCS )return ; + dev_priv = workload->vgpu->gvt->dev_priv; + ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; + ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +if (save) { workload->oactxctrl = reg_state[ctx_oactxctrl +1 ];
Quoting Colin Ian King (2018-03-21 19:18:28)
Quoted 8 lines · Joe Perches
Quoted 7 lines · Colin King
Quoted 6 lines
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
Maybe true, but is it possible for workload to be null? Maybe the null test should be removed instead.
From what I understand from the static analysis, there may be a potential for workload to be null, I couldn't rule it out so I went with the more paranoid stance of keeping the null check in.
Not sr_oa_regs() problem if workload is NULL, that's the callers. I reviewed the identical patch yesterday, and we ended up with removing the NULL checks, just keeping the workload->id != RCS. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · Chris Wilson
Quoting Colin Ian King (2018-03-21 19:18:28)
Quoted 13 lines · Joe Perches
Quoted 11 lines · Colin King
Quoted 7 lines
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
Maybe true, but is it possible for workload to be null? Maybe the null test should be removed instead.
Quoted 9 lines
Quoted 3 lines
From what I understand from the static analysis, there may be a potential for workload to be null, I couldn't rule it out so I went with the more paranoid stance of keeping the null check in.
Not
sr_oa_regs()problem if workload is NULL, that's the callers. I reviewed the identical patch yesterday, and we ended up with removing the NULL checks, just keeping theworkload->id!= RCS. -Chris
Ah, OK, thanks for the clarification Chris.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Colin Ian King
Quoted 7 lines · Joe Perches
Quoted 6 lines · Colin King
From: Colin Ian King <[email protected]>
The pointer workload is dereferenced before it is null checked, hence there is a potential for a null pointer dereference on workload. Fix this by only dereferencing workload after it is null checked.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Detected by CoverityScan, CID#1466017 ("Dereference before null check")
Maybe true, but is it possible for workload to be null? Maybe the null test should be removed instead.
From what I understand from the static analysis, there may be a potential for workload to be null, I couldn't rule it out so I went with the more paranoid stance of keeping the null check in.
workload cannot be null here.
Look at the uses of sr_oa_regs and see that
workload has already been dereferenced.
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Fixes fa3dd623e559 ("drm/i915/gvt: keep oa config in shadow ctx")Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/i915/gvt/scheduler.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gvt/scheduler.c +3
-3@@ -60,9 +60,9 @@ static void set_context_pdp_root_pointer(static void sr_oa_regs (struct intel_vgpu_workload *workload,u32 *reg_state,bool save) { -struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv; -u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; -u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +struct drm_i915_private *dev_priv; +u32 ctx_oactxctrl; +u32 ctx_flexeu0;int i =0 ;u32 flex_mmio[] = {i915_mmio_reg_offset (EU_PERF_CNTL0 ),@@ -77,6 +77,10 @@ static void sr_oa_regs(struct intel_vgpu_workload *workload,if (!workload || !reg_state || workload->ring_id !=RCS )return ;
Quoted 9 lines
Quoted 7 lines
drivers/gpu/drm/i915/gvt/scheduler.c static void sr_oa_regs(struct intel_vgpu_workload *workload, · line 86
Quoted 7 lines
drivers/gpu/drm/i915/gvt/scheduler.c +4
-0+ dev_priv = workload->vgpu->gvt->dev_priv; + ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; + ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; +if (save) { workload->oactxctrl = reg_state[ctx_oactxctrl +1 ];
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915/gvt: don't dereference 'workload' before null checking it
In reply to Colin King== Series Details ==
== Series Details ==
Series: drm/i915/gvt: don't dereference 'workload' before null checking it
URL : https://patchwork.freedesktop.org/series/40401/
State : success
== Summary ==
Series 40401v1 drm/i915/gvt: don't dereference 'workload' before null checking it
https://patchwork.freedesktop.org/api/1.0/series/40401/revisions/1/mbox/
---- Possible new issues:
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
incomplete -> PASS (fi-bxt-dsi)---- Known issues:
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
pass -> DMESG-WARN (fi-skl-6700k2) fdo#103191
Subgroup suspend-read-crc-pipe-c:
notrun -> INCOMPLETE (fi-bxt-dsi) fdo#103927fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:429s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:446s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:381s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:533s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:301s fi-bxt-dsi total:243 pass:216 dwarn:0 dfail:0 fail:0 skip:26 fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:511s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:516s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:505s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:409s fi-cfl-s2 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:573s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:518s fi-cnl-drrs total:285 pass:254 dwarn:3 dfail:0 fail:0 skip:28 time:519s fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:585s fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:426s fi-gdg-551 total:285 pass:177 dwarn:0 dfail:0 fail:0 skip:108 time:319s fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:531s fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:401s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:418s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:474s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:431s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:476s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:471s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:521s fi-pnv-d510 total:285 pass:219 dwarn:1 dfail:0 fail:0 skip:65 time:655s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:438s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:539s fi-skl-6700k2 total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:506s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:504s fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:428s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:444s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:580s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:400s
d1aafb635a5ff976b7b3164a6aff86f29871d415 drm-tip: 2018y-03m-21d-17h-25m-04s UTC integration manifest 3d5a04a9e1d2 drm/i915/gvt: don't dereference 'workload' before null checking it
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8437/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/i915/gvt: don't dereference 'workload' before null checking it
In reply to Colin King== Series Details ==
== Series Details ==
Series: drm/i915/gvt: don't dereference 'workload' before null checking it
URL : https://patchwork.freedesktop.org/series/40401/
State : success
== Summary ==
---- Known issues:
Test kms_cursor_crc:
Subgroup cursor-64x64-suspend:
incomplete -> PASS (shard-hsw) fdo#103540
Test kms_fbcon_fbt:
Subgroup fbc-suspend:
incomplete -> PASS (shard-hsw) fdo#104874
Test kms_flip:
Subgroup 2x-wf_vblank-ts-check-interruptible:
pass -> FAIL (shard-hsw) fdo#100368fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#104874 https://bugs.freedesktop.org/show_bug.cgi?id=104874
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
shard-apl total:3478 pass:1814 dwarn:1 dfail:0 fail:7 skip:1655 time:13121s shard-hsw total:3478 pass:1767 dwarn:1 dfail:0 fail:2 skip:1707 time:11881s shard-snb total:3478 pass:1357 dwarn:1 dfail:0 fail:3 skip:2117 time:7269s
Blacklisted hosts:
shard-kbl total:3478 pass:1898 dwarn:40 dfail:0 fail:10 skip:1530 time:9934s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8437/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx