dma-buf: Discard old fence_excl on retrying get_fences_rcu for realloc
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 4 Jun 2019 12:53:23 +0000 (13:53 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 5 Jun 2019 06:38:37 +0000 (07:38 +0100)
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 <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 #v4.10
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190604125323.21396-1-chris@chris-wilson.co.uk
drivers/dma-buf/reservation.c

index 4d32e2c678626f35d2654d38148643fa65784875..4447e13d1e891881f8ff6046ae442333b2293e30 100644 (file)
@@ -365,6 +365,10 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
                                           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;