Skip to content

Commit

Permalink
gpu: host1x: Plug potential memory leak
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
  • Loading branch information
thierryreding committed Sep 16, 2021
1 parent a81cf83 commit c3dbfb9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/host1x/fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c3dbfb9

Please sign in to comment.