From: Chris Wilson <ch...@chris-wilson.co.uk>

commit f5b07b04e5f090a85d1e96938520f2b2b58e4a8e upstream.

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")
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vet...@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
Cc: Christian König <christian.koe...@amd.com>
Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: Sumit Semwal <sumit.sem...@linaro.org>
Cc: sta...@vger.kernel.org #v4.10
Reviewed-by: Christian König <christian.koe...@amd.com>
Link: 
https://patchwork.freedesktop.org/patch/msgid/20190604125323.21396-1-ch...@chris-wilson.co.uk
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 drivers/dma-buf/reservation.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -357,6 +357,10 @@ int reservation_object_get_fences_rcu(st
                                           GFP_NOWAIT | __GFP_NOWARN);
                        if (!nshared) {
                                rcu_read_unlock();
+
+                               dma_fence_put(fence_excl);
+                               fence_excl = NULL;
+
                                nshared = krealloc(shared, sz, GFP_KERNEL);
                                if (nshared) {
                                        shared = nshared;


Reply via email to