Commit 72c7d625 authored by Hyejeong Choi's avatar Hyejeong Choi Committed by Christian König
Browse files

dma-buf: insert memory barrier before updating num_fences



smp_store_mb() inserts memory barrier after storing operation.
It is different with what the comment is originally aiming so Null
pointer dereference can be happened if memory update is reordered.

Signed-off-by: default avatarHyejeong Choi <hjeong.choi@samsung.com>
Fixes: a590d0fd ("dma-buf: Update reservation shared_count after adding the new fence")
CC: stable@vger.kernel.org
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250513020638.GA2329653@au1-maretx-p37.eng.sarc.samsung.com


Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
parent 2f0c6fce
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -320,8 +320,9 @@ void dma_resv_add_fence(struct dma_resv *obj, struct dma_fence *fence,
	count++;

	dma_resv_list_set(fobj, i, fence, usage);
	/* pointer update must be visible before we extend the num_fences */
	smp_store_mb(fobj->num_fences, count);
	/* fence update must be visible before we extend the num_fences */
	smp_wmb();
	fobj->num_fences = count;
}
EXPORT_SYMBOL(dma_resv_add_fence);