summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2021-09-02 22:33:09 +0200
committerThierry Reding <treding@nvidia.com>2021-09-16 18:06:52 +0200
commitc3dbfb9c49eef7d07904e5fd5e158dd6688bbab3 (patch)
tree3d8ec9d2961d2062d5dfda65fee5a40f18c68154
parenta81cf839a064af27349b857fe347e97dd98c12a0 (diff)
gpu: host1x: Plug potential memory leakdrm/tegra/for-5.15-rc3
The memory allocated for a DMA fence could be leaked if the code failed to allocate the waiter object. Make sure to release the fence allocation on failure. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/host1x/fence.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
index e49083b0b09e..ecab72882192 100644
--- a/drivers/gpu/host1x/fence.c
+++ b/drivers/gpu/host1x/fence.c
@@ -152,8 +152,10 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold)
return ERR_PTR(-ENOMEM);
fence->waiter = kzalloc(sizeof(*fence->waiter), GFP_KERNEL);
- if (!fence->waiter)
+ if (!fence->waiter) {
+ kfree(fence);
return ERR_PTR(-ENOMEM);
+ }
fence->sp = sp;
fence->threshold = threshold;