Commit 2b4abf87 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Rob Clark
Browse files

drm/msm/adreno: fix userspace-triggered crash on a2xx-a4xx



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: a452510a ("drm/msm/adreno: Switch to the common UBWC config struct")
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: default avatarRob Clark <rob.clark@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/717778/


Message-ID: <20260411-adreno-fix-ubwc-v3-1-4983156f3f80@oss.qualcomm.com>
Signed-off-by: default avatarRob Clark <robin.clark@oss.qualcomm.com>
parent e64bca63
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -424,15 +424,21 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
		*value = vm->mm_range;
		return 0;
	case MSM_PARAM_HIGHEST_BANK_BIT:
		if (!adreno_gpu->ubwc_config)
			return UERR(ENOENT, drm, "no UBWC on this platform");
		*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:
		if (!adreno_gpu->ubwc_config)
			return UERR(ENOENT, drm, "no UBWC on this platform");
		*value = adreno_gpu->ubwc_config->ubwc_swizzle;
		return 0;
	case MSM_PARAM_MACROTILE_MODE:
		if (!adreno_gpu->ubwc_config)
			return UERR(ENOENT, drm, "no UBWC on this platform");
		*value = adreno_gpu->ubwc_config->macrotile_mode;
		return 0;
	case MSM_PARAM_UCHE_TRAP_BASE: