From aa3decfdb85ff7075c53ebced8fd0e63cc97755b Mon Sep 17 00:00:00 2001 From: Mainak Sen Date: Thu, 30 Jan 2025 08:29:09 +0000 Subject: [PATCH] gpu: host1x: Add plausibility check on Host1x calibration data When syncpoint and channel property are read from device-tree, add plausibility check to validate against reference data. Jira HOSTX-5843 Change-Id: I66dd9a5f18200aa8baaeecd36499dfb0ca24ba01 Signed-off-by: Mainak Sen Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3293524 GVS: buildbot_gerritrpt Reviewed-by: Mikko Perttunen Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/host1x/dev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index d7ab4c9b..e4b4b2bf 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -930,6 +930,10 @@ static int host1x_get_assigned_resources(struct host1x *host) if (err == 0) { host->channel_base = vals[0]; host->num_channels = vals[1]; + if (host->channel_base + host->num_channels > host->info->nb_channels) { + dev_err(host->dev, "invalid value for nvidia,channels property"); + return -EINVAL; + } } else if (err == -EINVAL) { host->channel_base = 0; host->num_channels = host->info->nb_channels; @@ -942,6 +946,10 @@ static int host1x_get_assigned_resources(struct host1x *host) if (err == 0) { host->syncpt_base = vals[0]; host->syncpt_end = vals[0] + vals[1]; + if (host->syncpt_end > host->info->nb_pts) { + dev_err(host->dev, "invalid value for nvidia,syncpoints property"); + return -EINVAL; + } } else if (err == -EINVAL) { host->syncpt_base = 0; host->syncpt_end = host->info->nb_pts;