dma-fence: fix free sync object incorrectly
Subsystems (3)
PATCH 1/1 dma-fence: fix free sync object incorrectly
The function dma_fence_free() works fine because struct dma_fence is the first member of sync object.
Use kfree make it more reasonable.
--- drivers/dma-buf/dma-fence-array.c | 2 +- drivers/dma-buf/dma-fence-chain.c | 2 +- drivers/dma-buf/sw_sync.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/dma-buf/dma-fence-array.c +1 -1
@@ -120,7 +120,7 @@ static void dma_fence_array_release(struct dma_fence *fence)dma_fence_put (array->fences[i]);kfree (array->fences); -dma_fence_free (fence); +kfree (array); }const struct dma_fence_ops dma_fence_array_ops = {
drivers/dma-buf/dma-fence-chain.c +1 -1
@@ -203,7 +203,7 @@ static void dma_fence_chain_release(struct dma_fence *fence)dma_fence_put (prev);dma_fence_put (chain->fence); -dma_fence_free (fence); +kfree (chain); }const struct dma_fence_ops dma_fence_chain_ops = {
drivers/dma-buf/sw_sync.c +1 -1
@@ -142,7 +142,7 @@ static void timeline_fence_release(struct dma_fence *fence)spin_unlock_irqrestore (fence->lock, flags);sync_timeline_put (parent); -dma_fence_free (fence); +kfree (pt); }static bool timeline_fence_signaled (struct dma_fence *fence)
Signature · 1 line
2.17.1
Christian König
maintainerAm 05.03.22 um 13:17 schrieb wangshumin:
Quoted 4 lines
The function
dma_fence_free()works fine because structdma_fenceis the first member of sync object.Use
kfreemake it more reasonable.
Well, NAK. You haven't understood what this is good for.
All dma_fence implementations must free their memory RCU safe. In other words they must use kfree_rcu() using the rcu member in the base dma_fence object.
dma_fence_free() is now a wrapper around that to better abstract the functionality.
Your patch would break that and cause hard to debug memory corruptions.
We could potentially rename the function to make the functionality more clear, but this here is just bluntly nonsense.
Regards,
Christian.
Quoted 47 lines
Signed-off-by wangshumin <[email protected]>--- drivers/dma-buf/dma-fence-array.c | 2 +- drivers/dma-buf/dma-fence-chain.c | 2 +- drivers/dma-buf/sw_sync.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/dma-buf/dma-fence-array.c +1
-1@@ -120,7 +120,7 @@ static void dma_fence_array_release(struct dma_fence *fence)dma_fence_put (array->fences[i]);kfree (array->fences); -dma_fence_free (fence); +kfree (array); }const struct dma_fence_ops dma_fence_array_ops = {drivers/dma-buf/dma-fence-chain.c +1
-1@@ -203,7 +203,7 @@ static void dma_fence_chain_release(struct dma_fence *fence)dma_fence_put (prev);dma_fence_put (chain->fence); -dma_fence_free (fence); +kfree (chain); }const struct dma_fence_ops dma_fence_chain_ops = {drivers/dma-buf/sw_sync.c +1
-1@@ -142,7 +142,7 @@ static void timeline_fence_release(struct dma_fence *fence)spin_unlock_irqrestore (fence->lock, flags);sync_timeline_put (parent); -dma_fence_free (fence); +kfree (pt); }static bool timeline_fence_signaled (struct dma_fence *fence)