drivers/gpu/drm/msm/adreno/adreno_gpu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
Before a5xx Adreno driver will not try fetching UBWC params (because
those generations didn't support UBWC anyway), however it's still
possible to query UBWC-related params from the userspace, triggering
possible NULL pointer dereference. Check for UBWC config in
adreno_get_param() and return sane defaults if there is none.
Fixes: a452510aad53 ("drm/msm/adreno: Switch to the common UBWC config struct")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index d5fe6f6f0dec..7dc95c0a17f7 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -426,16 +426,25 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
*value = vm->mm_range;
return 0;
case MSM_PARAM_HIGHEST_BANK_BIT:
- *value = adreno_gpu->ubwc_config->highest_bank_bit;
+ if (!adreno_gpu->ubwc_config)
+ *value = 13;
+ else
+ *value = adreno_gpu->ubwc_config->highest_bank_bit;
return 0;
case MSM_PARAM_RAYTRACING:
*value = adreno_gpu->has_ray_tracing;
return 0;
case MSM_PARAM_UBWC_SWIZZLE:
- *value = adreno_gpu->ubwc_config->ubwc_swizzle;
+ if (!adreno_gpu->ubwc_config)
+ *value = 0;
+ else
+ *value = adreno_gpu->ubwc_config->ubwc_swizzle;
return 0;
case MSM_PARAM_MACROTILE_MODE:
- *value = adreno_gpu->ubwc_config->macrotile_mode;
+ if (!adreno_gpu->ubwc_config)
+ *value = 0;
+ else
+ *value = adreno_gpu->ubwc_config->macrotile_mode;
return 0;
case MSM_PARAM_UCHE_TRAP_BASE:
*value = adreno_gpu->uche_trap_base;
---
base-commit: 36ece9697e89016181e5ae87510e40fb31d86f2b
change-id: 20260407-adreno-fix-ubwc-6a2564710e21
Best regards,
--
With best wishes
Dmitry
On Mon, Apr 6, 2026 at 3:14 PM Dmitry Baryshkov
<dmitry.baryshkov@oss.qualcomm.com> wrote:
>
> Before a5xx Adreno driver will not try fetching UBWC params (because
> those generations didn't support UBWC anyway), however it's still
> possible to query UBWC-related params from the userspace, triggering
> possible NULL pointer dereference. Check for UBWC config in
> adreno_get_param() and return sane defaults if there is none.
>
> Fixes: a452510aad53 ("drm/msm/adreno: Switch to the common UBWC config struct")
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index d5fe6f6f0dec..7dc95c0a17f7 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -426,16 +426,25 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
> *value = vm->mm_range;
> return 0;
> case MSM_PARAM_HIGHEST_BANK_BIT:
> - *value = adreno_gpu->ubwc_config->highest_bank_bit;
> + if (!adreno_gpu->ubwc_config)
> + *value = 13;
> + else
> + *value = adreno_gpu->ubwc_config->highest_bank_bit;
These three params are only used by userspace on a6xx, so tbh it would
be ok to return -ENOENT for platforms that have no ubwc config. That
might be better than returning imaginary values.
BR,
-R
> return 0;
> case MSM_PARAM_RAYTRACING:
> *value = adreno_gpu->has_ray_tracing;
> return 0;
> case MSM_PARAM_UBWC_SWIZZLE:
> - *value = adreno_gpu->ubwc_config->ubwc_swizzle;
> + if (!adreno_gpu->ubwc_config)
> + *value = 0;
> + else
> + *value = adreno_gpu->ubwc_config->ubwc_swizzle;
> return 0;
> case MSM_PARAM_MACROTILE_MODE:
> - *value = adreno_gpu->ubwc_config->macrotile_mode;
> + if (!adreno_gpu->ubwc_config)
> + *value = 0;
> + else
> + *value = adreno_gpu->ubwc_config->macrotile_mode;
> return 0;
> case MSM_PARAM_UCHE_TRAP_BASE:
> *value = adreno_gpu->uche_trap_base;
>
> ---
> base-commit: 36ece9697e89016181e5ae87510e40fb31d86f2b
> change-id: 20260407-adreno-fix-ubwc-6a2564710e21
>
> Best regards,
> --
> With best wishes
> Dmitry
>
On Mon, Apr 06, 2026 at 03:24:43PM -0700, Rob Clark wrote:
> On Mon, Apr 6, 2026 at 3:14 PM Dmitry Baryshkov
> <dmitry.baryshkov@oss.qualcomm.com> wrote:
> >
> > Before a5xx Adreno driver will not try fetching UBWC params (because
> > those generations didn't support UBWC anyway), however it's still
> > possible to query UBWC-related params from the userspace, triggering
> > possible NULL pointer dereference. Check for UBWC config in
> > adreno_get_param() and return sane defaults if there is none.
> >
> > Fixes: a452510aad53 ("drm/msm/adreno: Switch to the common UBWC config struct")
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> > ---
> > drivers/gpu/drm/msm/adreno/adreno_gpu.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > index d5fe6f6f0dec..7dc95c0a17f7 100644
> > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > @@ -426,16 +426,25 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
> > *value = vm->mm_range;
> > return 0;
> > case MSM_PARAM_HIGHEST_BANK_BIT:
> > - *value = adreno_gpu->ubwc_config->highest_bank_bit;
> > + if (!adreno_gpu->ubwc_config)
> > + *value = 13;
> > + else
> > + *value = adreno_gpu->ubwc_config->highest_bank_bit;
>
> These three params are only used by userspace on a6xx, so tbh it would
> be ok to return -ENOENT for platforms that have no ubwc config. That
> might be better than returning imaginary values.
I'd say, those are defaults. But I agree, -ENOENT might be better.
>
> BR,
> -R
>
> > return 0;
> > case MSM_PARAM_RAYTRACING:
> > *value = adreno_gpu->has_ray_tracing;
> > return 0;
> > case MSM_PARAM_UBWC_SWIZZLE:
> > - *value = adreno_gpu->ubwc_config->ubwc_swizzle;
> > + if (!adreno_gpu->ubwc_config)
> > + *value = 0;
> > + else
> > + *value = adreno_gpu->ubwc_config->ubwc_swizzle;
> > return 0;
> > case MSM_PARAM_MACROTILE_MODE:
> > - *value = adreno_gpu->ubwc_config->macrotile_mode;
> > + if (!adreno_gpu->ubwc_config)
> > + *value = 0;
> > + else
> > + *value = adreno_gpu->ubwc_config->macrotile_mode;
> > return 0;
> > case MSM_PARAM_UCHE_TRAP_BASE:
> > *value = adreno_gpu->uche_trap_base;
> >
> > ---
> > base-commit: 36ece9697e89016181e5ae87510e40fb31d86f2b
> > change-id: 20260407-adreno-fix-ubwc-6a2564710e21
> >
> > Best regards,
> > --
> > With best wishes
> > Dmitry
> >
--
With best wishes
Dmitry
© 2016 - 2026 Red Hat, Inc.