From 41496b359d858e1c28840eaee2e2e6bba485c642 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Tue, 24 Oct 2017 17:22:55 +0530 Subject: gpu: nvgpu: check gpfifo before submit work User can call submit IOCTL before alloc_gpfifo IOCTL and can easily cause a kernel panic. The fix checks for a valid gpfifo.mem before proceeding with the submitted work. Bug 1968309 Change-Id: I5c1fc6f52b25426cd45e58e8b2e0e5bc6aa0c32f Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/1584519 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 590506d6..0d011b06 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -2547,6 +2547,9 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, if (c->has_timedout) return -ETIMEDOUT; + if (!nvgpu_mem_is_valid(&c->gpfifo.mem)) + return -ENOMEM; + /* fifo not large enough for request. Return error immediately. * Kernel can insert gpfifo entries before and after user gpfifos. * So, add extra_entries in user request. Also, HW with fifo size N -- cgit v1.2.2