drm/msm: prevent NULL dereference in msm_gpu_crashstate_capture()
Subsystems (4)
PATCH 1/1 drm/msm: prevent NULL dereference in msm_gpu_crashstate_capture()
Coverity complains of a possible NULL dereference:
CID 120718 (#1 of 1): Dereference null return value (NULL_RETURNS)
23. dereference: Dereferencing a pointer that might be NULL state->bos when calling msm_gpu_crashstate_get_bo. [show details]
301 msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
302 submit->bos[i].iova, submit->bos[i].flags);
Fix this by employing the same state->bos NULL check as is used in the next for loop.
--- drivers/gpu/drm/msm/msm_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpu.c +1 -1
@@ -296,7 +296,7 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu, state->bos =kcalloc (nr,sizeof (struct msm_gpu_state_bo ),GFP_KERNEL ); -for (i =0 ; i < submit->nr_bos; i++) { +for (i =0 ; state->bos && i < submit->nr_bos; i++) {if (should_dump (submit, i)) {msm_gpu_crashstate_get_bo (state, submit->bos[i].obj, submit->bos[i].iova, submit->bos[i].flags);
Signature · 1 line
2.33.0
Quoted 11 lines · Tim Gardner
Coverity complains of a possible NULL dereference:
CID 120718 (#1 of 1): Dereference null return value (
NULL_RETURNS)
23. dereference: Dereferencing a pointer that might be NULLstate->boswhen callingmsm_gpu_crashstate_get_bo. [show details]
301 msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
302 submit->bos[i].iova, submit->bos[i].flags);Fix this by employing the same
state->bosNULL check as is used in the next for loop.
Quoted 9 lines
Cc Rob Clark <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Tim Gardner <[email protected]>
Quoted 18 lines
--- drivers/gpu/drm/msm/msm_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gpu.c +1
-1@@ -296,7 +296,7 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu, state->bos =kcalloc (nr,sizeof (struct msm_gpu_state_bo ),GFP_KERNEL ); -for (i =0 ; i < submit->nr_bos; i++) { +for (i =0 ; state->bos && i < submit->nr_bos; i++) {if (should_dump (submit, i)) {msm_gpu_crashstate_get_bo (state, submit->bos[i].obj, submit->bos[i].iova, submit->bos[i].flags);
Signature · 2 lines
With best wishes Dmitry