Skip to content

Commit 72c7d62

Browse files
Hyejeong ChoiChristianKoenigAMD
authored andcommitted
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: Hyejeong Choi <hjeong.choi@samsung.com> Fixes: a590d0f ("dma-buf: Update reservation shared_count after adding the new fence") CC: stable@vger.kernel.org Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://lore.kernel.org/r/20250513020638.GA2329653@au1-maretx-p37.eng.sarc.samsung.com Signed-off-by: Christian König <christian.koenig@amd.com>
1 parent 2f0c6fc commit 72c7d62

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/dma-buf/dma-resv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ void dma_resv_add_fence(struct dma_resv *obj, struct dma_fence *fence,
320320
count++;
321321

322322
dma_resv_list_set(fobj, i, fence, usage);
323-
/* pointer update must be visible before we extend the num_fences */
324-
smp_store_mb(fobj->num_fences, count);
323+
/* fence update must be visible before we extend the num_fences */
324+
smp_wmb();
325+
fobj->num_fences = count;
325326
}
326327
EXPORT_SYMBOL(dma_resv_add_fence);
327328

0 commit comments

Comments
 (0)