[Openpvrsgx-devgroup] [PATCH] pvrsgx: Fix resource leak

David Shah dave at ds0.me
Wed Jun 10 16:04:49 CEST 2020


A missing call to PVRSRVRelease means that dmabufs are leaked by the
driver, particularly if applications aren't closed properly. This was
particularly noticeable with TILER due to the limited TILER space and
current 8192-wide allocations.

Tested on 5.6.y

Signed-off-by: David Shah <dave at ds0.me>
---
 drivers/gpu/drm/pvrsgx/pvr-drv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/pvrsgx/pvr-drv.c b/drivers/gpu/drm/pvrsgx/pvr-drv.c
index 61c45f8a2fb0..0ea0022b3d79 100644
--- a/drivers/gpu/drm/pvrsgx/pvr-drv.c
+++ b/drivers/gpu/drm/pvrsgx/pvr-drv.c
@@ -75,6 +75,15 @@ static int pvr_open(struct drm_device *dev, struct drm_file *file)
 	return PVRSRVOpen(dev, file);
 }
 
+static void pvr_postclose(struct drm_device *dev, struct drm_file *file)
+{
+	dev_dbg(dev->dev, "%s\n", __func__);
+
+	PVRSRVRelease(file->driver_priv);
+
+	file->driver_priv = NULL;
+}
+
 static int pvr_ioctl_command(struct drm_device *dev, void *arg, struct drm_file *filp)
 {
 	dev_dbg(dev->dev, "%s: dev: %px arg: %px filp: %px\n", __func__, dev, arg, filp);
@@ -140,6 +149,7 @@ static struct drm_driver pvr_drm_driver = {
 	.driver_features = DRIVER_RENDER,
 	.dev_priv_size = 0,
 	.open = pvr_open,
+	.postclose = pvr_postclose,
 	.ioctls = pvr_ioctls,
 	.num_ioctls = ARRAY_SIZE(pvr_ioctls),
 	.fops = &pvr_fops,
-- 
2.26.2



More information about the openpvrsgx-devgroup mailing list