Message ID | 20190604123947.20713-1-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dma-buf: Discard old fence_excl on retrying get_fences_rcu for realloc | expand |
Am 04.06.19 um 14:39 schrieb Chris Wilson: > If we have to drop the seqcount & rcu lock to perform a krealloc, we > have to restart the loop. In doing so, be careful not to lose track of > the already acquired exclusive fence. > > Fixes: fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes") #v4.10 > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> > Cc: Christian König <christian.koenig@amd.com> > Cc: Alex Deucher <alexander.deucher@amd.com> > Cc: Sumit Semwal <sumit.semwal@linaro.org> > Cc: stable@vger.kernel.org > --- > drivers/dma-buf/reservation.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c > index 4d32e2c67862..704503df4892 100644 > --- a/drivers/dma-buf/reservation.c > +++ b/drivers/dma-buf/reservation.c > @@ -365,6 +365,12 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, > GFP_NOWAIT | __GFP_NOWARN); > if (!nshared) { > rcu_read_unlock(); > + > + if (fence_excl) { > + dma_fence_put(fence_excl); > + fence_excl = NULL; > + } > + dma_fence_put is NULL save, so no need for the if. But apart from that a good catch, Christian. > nshared = krealloc(shared, sz, GFP_KERNEL); > if (nshared) { > shared = nshared;
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 4d32e2c67862..704503df4892 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -365,6 +365,12 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, GFP_NOWAIT | __GFP_NOWARN); if (!nshared) { rcu_read_unlock(); + + if (fence_excl) { + dma_fence_put(fence_excl); + fence_excl = NULL; + } + nshared = krealloc(shared, sz, GFP_KERNEL); if (nshared) { shared = nshared;
If we have to drop the seqcount & rcu lock to perform a krealloc, we have to restart the loop. In doing so, be careful not to lose track of the already acquired exclusive fence. Fixes: fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes") #v4.10 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: stable@vger.kernel.org --- drivers/dma-buf/reservation.c | 6 ++++++ 1 file changed, 6 insertions(+)