Skip to content

Commit 517feec

Browse files
rtg-canonicalgregkh
authored andcommitted
drm/msm: prevent NULL dereference in msm_gpu_crashstate_capture()
[ Upstream commit b220c15 ] 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. Cc: Rob Clark <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Tim Gardner <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Rob Clark <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent e1d7f02 commit 517feec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu,
376376
state->bos = kcalloc(nr,
377377
sizeof(struct msm_gpu_state_bo), GFP_KERNEL);
378378

379-
for (i = 0; i < submit->nr_bos; i++) {
379+
for (i = 0; state->bos && i < submit->nr_bos; i++) {
380380
if (should_dump(submit, i)) {
381381
msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
382382
submit->bos[i].iova, submit->bos[i].flags);

0 commit comments

Comments
 (0)