drm/msm/adreno: fix use after free on error path in a6xx_gpu_init()
Subsystems (5)
PATCH 1/1 drm/msm/adreno: fix use after free on error path in a6xx_gpu_init()
The a6xx_destroy() function frees "a6xx_gpu" and so "adreno_gpu" points to freed memory. Preserve the error code before freeing the memory to avoid a use after free.
Fixes d158886cba08 ("drm/msm/adreno: Trust the SSoT UBWC config")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -1
@@ -2770,8 +2770,9 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->ubwc_config =qcom_ubwc_config_get_data ();if (IS_ERR (adreno_gpu->ubwc_config)) { + ret =PTR_ERR (adreno_gpu->ubwc_config);a6xx_destroy (&(a6xx_gpu->base.base)); -return ERR_CAST (adreno_gpu->ubwc_config); +return ERR_PTR (ret); }/* Set up the preemption specific bits and pieces for each ringbuffer */
Signature · 1 line
2.53.0
Quoted 7 lines · Dan Carpenter
The
a6xx_destroy()function frees "a6xx_gpu" and so "adreno_gpu" points to freed memory. Preserve the error code before freeing the memory to avoid a use after free.Fixes d158886cba08 ("drm/msm/adreno: Trust the SSoT UBWC config")Signed-off-by Dan Carpenter <[email protected]>---
Reviewed-by Konrad Dybcio <[email protected]>
Konrad
Quoted 10 lines · Dan Carpenter
The
a6xx_destroy()function frees "a6xx_gpu" and so "adreno_gpu" points to freed memory. Preserve the error code before freeing the memory to avoid a use after free.Fixes d158886cba08 ("drm/msm/adreno: Trust the SSoT UBWC config")Signed-off-by Dan Carpenter <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by Dmitry Baryshkov <[email protected]>
Signature · 2 lines
With best wishes Dmitry