diff mbox series

[3/4] drm/panthor: Reset the FW VM to NULL on unplug

Message ID 20240502183813.1612017-4-boris.brezillon@collabora.com (mailing list archive)
State New, archived
Headers show
Series drm/panthor: More reset fixes | expand

Commit Message

Boris Brezillon May 2, 2024, 6:38 p.m. UTC
This way get NULL derefs instead of use-after-free if the FW VM is
referenced after the device has been unplugged.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/gpu/drm/panthor/panthor_fw.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steven Price May 3, 2024, 9:22 a.m. UTC | #1
On 02/05/2024 19:38, Boris Brezillon wrote:
> This way get NULL derefs instead of use-after-free if the FW VM is
> referenced after the device has been unplugged.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>  drivers/gpu/drm/panthor/panthor_fw.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
> index b41685304a83..93165961a6b5 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw.c
> +++ b/drivers/gpu/drm/panthor/panthor_fw.c
> @@ -1141,6 +1141,7 @@ void panthor_fw_unplug(struct panthor_device *ptdev)
>  	 * state to keep the active_refcnt balanced.
>  	 */
>  	panthor_vm_put(ptdev->fw->vm);
> +	ptdev->fw->vm = NULL;
>  
>  	panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000);
>  }
Liviu Dudau May 3, 2024, 11:47 a.m. UTC | #2
On Fri, May 03, 2024 at 10:22:13AM +0100, Steven Price wrote:
> On 02/05/2024 19:38, Boris Brezillon wrote:
> > This way get NULL derefs instead of use-after-free if the FW VM is
> > referenced after the device has been unplugged.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> 
> Reviewed-by: Steven Price <steven.price@arm.com>

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

> 
> > ---
> >  drivers/gpu/drm/panthor/panthor_fw.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
> > index b41685304a83..93165961a6b5 100644
> > --- a/drivers/gpu/drm/panthor/panthor_fw.c
> > +++ b/drivers/gpu/drm/panthor/panthor_fw.c
> > @@ -1141,6 +1141,7 @@ void panthor_fw_unplug(struct panthor_device *ptdev)
> >  	 * state to keep the active_refcnt balanced.
> >  	 */
> >  	panthor_vm_put(ptdev->fw->vm);
> > +	ptdev->fw->vm = NULL;
> >  
> >  	panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000);
> >  }
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
index b41685304a83..93165961a6b5 100644
--- a/drivers/gpu/drm/panthor/panthor_fw.c
+++ b/drivers/gpu/drm/panthor/panthor_fw.c
@@ -1141,6 +1141,7 @@  void panthor_fw_unplug(struct panthor_device *ptdev)
 	 * state to keep the active_refcnt balanced.
 	 */
 	panthor_vm_put(ptdev->fw->vm);
+	ptdev->fw->vm = NULL;
 
 	panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000);
 }