summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorJordan Crouse <jcrouse@codeaurora.org>2019-05-31 16:09:38 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-31 07:24:42 +0200
commit9a08330437d65334e3ca600ef4fdb49177f9f880 (patch)
tree1cffd0126e1c522dfedba1906ee963466527c2a7 /drivers/gpu/drm
parent3543f9977de4888da88fc9085e6357db88e9fcca (diff)
downloadlinux-stable-9a08330437d65334e3ca600ef4fdb49177f9f880.tar.gz
linux-stable-9a08330437d65334e3ca600ef4fdb49177f9f880.tar.bz2
linux-stable-9a08330437d65334e3ca600ef4fdb49177f9f880.zip
drm/msm/adreno: Ensure that the zap shader region is big enough
[ Upstream commit 6672e11cad662ce6631e04c38f92a140a99c042c ] Before loading the zap shader we should ensure that the reserved memory region is big enough to hold the loaded file. Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com> Signed-off-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index a9c0ac937b00..9acbbc0f3232 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -56,7 +56,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
return ret;
mem_phys = r.start;
- mem_size = resource_size(&r);
/* Request the MDT file for the firmware */
fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
@@ -72,6 +71,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
goto out;
}
+ if (mem_size > resource_size(&r)) {
+ DRM_DEV_ERROR(dev,
+ "memory region is too small to load the MDT\n");
+ ret = -E2BIG;
+ goto out;
+ }
+
/* Allocate memory for the firmware image */
mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
if (!mem_region) {