diff options
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 755fcdda5742..e00a1af5b77d 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -538,10 +538,12 @@ static int gk20a_channel_cycle_stats(struct channel_gk20a *ch, #endif static int gk20a_init_error_notifier(struct channel_gk20a *ch, - struct nvhost_set_error_notifier *args) { - void *va; - + struct nvhost_set_error_notifier *args) +{ + struct device *dev = dev_from_gk20a(ch->g); struct dma_buf *dmabuf; + void *va; + u64 end = args->offset + sizeof(struct nvhost_notification); if (!args->mem) { pr_err("gk20a_init_error_notifier: invalid memory handle\n"); @@ -557,6 +559,13 @@ static int gk20a_init_error_notifier(struct channel_gk20a *ch, pr_err("Invalid handle: %d\n", args->mem); return -EINVAL; } + + if (end > dmabuf->size || end < sizeof(struct nvhost_notification)) { + dma_buf_put(dmabuf); + gk20a_err(dev, "gk20a_init_error_notifier: invalid offset\n"); + return -EINVAL; + } + /* map handle */ va = dma_buf_vmap(dmabuf); if (!va) { |