diff mbox series

dma-buf: Fix one use-after-free of fence

Message ID 20220707080241.20060-1-xinhui.pan@amd.com (mailing list archive)
State New, archived
Headers show
Series dma-buf: Fix one use-after-free of fence | expand

Commit Message

Pan, Xinhui July 7, 2022, 8:02 a.m. UTC
Need get the new fence when we replace the old one.

Fixes: 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
---
 drivers/dma-buf/dma-resv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian König July 7, 2022, 8:05 a.m. UTC | #1
Am 07.07.22 um 10:02 schrieb xinhui pan:
> Need get the new fence when we replace the old one.
>
> Fixes: 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>

Good catch, Reviewed-by: Christian König <christian.koenig@amd.com>

Going to push that in a minute.

Christian.

> ---
>   drivers/dma-buf/dma-resv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index 0cce6e4ec946..205acb2c744d 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -343,7 +343,7 @@ void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
>   		if (old->context != context)
>   			continue;
>   
> -		dma_resv_list_set(list, i, replacement, usage);
> +		dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
>   		dma_fence_put(old);
>   	}
>   }
Alex Deucher July 28, 2022, 3:09 a.m. UTC | #2
Did this ever land?  I don't see it in drm-misc.

Alex

On Thu, Jul 7, 2022 at 4:05 AM Christian König <christian.koenig@amd.com> wrote:
>
> Am 07.07.22 um 10:02 schrieb xinhui pan:
> > Need get the new fence when we replace the old one.
> >
> > Fixes: 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")
> > Signed-off-by: xinhui pan <xinhui.pan@amd.com>
>
> Good catch, Reviewed-by: Christian König <christian.koenig@amd.com>
>
> Going to push that in a minute.
>
> Christian.
>
> > ---
> >   drivers/dma-buf/dma-resv.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> > index 0cce6e4ec946..205acb2c744d 100644
> > --- a/drivers/dma-buf/dma-resv.c
> > +++ b/drivers/dma-buf/dma-resv.c
> > @@ -343,7 +343,7 @@ void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
> >               if (old->context != context)
> >                       continue;
> >
> > -             dma_resv_list_set(list, i, replacement, usage);
> > +             dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
> >               dma_fence_put(old);
> >       }
> >   }
>
diff mbox series

Patch

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 0cce6e4ec946..205acb2c744d 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -343,7 +343,7 @@  void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
 		if (old->context != context)
 			continue;
 
-		dma_resv_list_set(list, i, replacement, usage);
+		dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
 		dma_fence_put(old);
 	}
 }