[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7d251b1c-1054-6fde-602f-35eed4ac1cfe@linaro.org>
Date: Sat, 2 Oct 2021 01:42:06 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Tim Gardner <tim.gardner@...onical.com>,
dri-devel@...ts.freedesktop.org
Cc: Rob Clark <robdclark@...il.com>, Sean Paul <sean@...rly.run>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, linux-arm-msm@...r.kernel.org,
freedreno@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/msm: prevent NULL dereference in
msm_gpu_crashstate_capture()
On 29/09/2021 19:25, Tim Gardner wrote:
> 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 <robdclark@...il.com>
> Cc: Sean Paul <sean@...rly.run>
> Cc: David Airlie <airlied@...ux.ie>
> Cc: Daniel Vetter <daniel@...ll.ch>
> Cc: linux-arm-msm@...r.kernel.org
> Cc: dri-devel@...ts.freedesktop.org
> Cc: freedreno@...ts.freedesktop.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Tim Gardner <tim.gardner@...onical.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
> ---
> drivers/gpu/drm/msm/msm_gpu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 8a3a592da3a4..2c46cd968ac4 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -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);
>
--
With best wishes
Dmitry
Powered by blists - more mailing lists