msm: kgsl: Initialize fence only if it gets refcount on timeline

kgsl_timeline_get can return NULL incase timeline pointer is NULL
or refcount on timeline already went to zero. Current code is not
checking this and going ahead with fence initialization which could
result in invalid pointer access. Fix this by ensuring fence got a
reference count on timeline before proceeding with initialization.

Change-Id: I14d1355b1ea45e854bef8acf4afef53e0f4ceefc
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
This commit is contained in:
Deepak Kumar 2021-03-22 11:28:43 +05:30
commit fcbe669554

View file

@ -299,6 +299,10 @@ struct dma_fence *kgsl_timeline_fence_alloc(struct kgsl_timeline *timeline,
return ERR_PTR(-ENOMEM);
fence->timeline = kgsl_timeline_get(timeline);
if (!fence->timeline) {
kfree(fence);
return ERR_PTR(-ENOENT);
}
dma_fence_init(&fence->base, &timeline_fence_ops,
&timeline->lock, timeline->context, seqno);