Skip to contentSkip to conversation

drm/amdgpu: fix drm_plane alloc in amdgpu_vkms

PATCH In review Flora Cui 2 participants 2 messages Dec 7, 2021 – Dec 8, 2021

Subsystems (2)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix drm_plane alloc in amdgpu_vkms

otherwise the drm_plane is not released

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +8 -13
index af3a2f8c12b4..0bf697b72ad0 100644
@@ -392,19 +392,14 @@ static struct drm_plane *amdgpu_vkms_plane_init(struct drm_device *dev,
 	struct drm_plane *plane;
 	int ret;
 
-	plane = kzalloc(sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
-
-	ret = drm_universal_plane_init(dev, plane, 1 << index,
-				       &amdgpu_vkms_plane_funcs,
-				       amdgpu_vkms_formats,
-				       ARRAY_SIZE(amdgpu_vkms_formats),
-				       NULL, type, NULL);
-	if (ret) {
-		kfree(plane);
-		return ERR_PTR(ret);
-	}
+	plane = __drmm_universal_plane_alloc(dev, sizeof(*plane), 0, 1 << index,
+					   &amdgpu_vkms_plane_funcs,
+					   amdgpu_vkms_formats,
+					   ARRAY_SIZE(amdgpu_vkms_formats),
+					   NULL, type, NULL);
+
+	if (IS_ERR(plane))
+		return plane;
 
 	drm_plane_helper_add(plane, &amdgpu_vkms_primary_helper_funcs);
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[Public]

Regards,
Guchun

-----Original Message-----
From: Cui, Flora <[email protected]>
Sent: Tuesday, December 7, 2021 3:12 PM
To: Chen, Guchun <[email protected]>; Yuan, Perry <[email protected]>; Shi, Leslie <[email protected]>; [email protected]
Cc: Cui, Flora <[email protected]>
Subject: [PATCH] drm/amdgpu: fix drm_plane alloc in amdgpu_vkms

otherwise the drm_plane is not released

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +8 -13
index af3a2f8c12b4..0bf697b72ad0 100644
@@ -392,19 +392,14 @@ static struct drm_plane *amdgpu_vkms_plane_init(struct drm_device *dev,
 	struct drm_plane *plane;
 	int ret;
 
-	plane = kzalloc(sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
-
-	ret = drm_universal_plane_init(dev, plane, 1 << index,
-				       &amdgpu_vkms_plane_funcs,
-				       amdgpu_vkms_formats,
-				       ARRAY_SIZE(amdgpu_vkms_formats),
-				       NULL, type, NULL);
-	if (ret) {
-		kfree(plane);
-		return ERR_PTR(ret);
-	}
+	plane = __drmm_universal_plane_alloc(dev, sizeof(*plane), 0, 1 << index,
+					   &amdgpu_vkms_plane_funcs,
+					   amdgpu_vkms_formats,
+					   ARRAY_SIZE(amdgpu_vkms_formats),
+					   NULL, type, NULL);
+
+	if (IS_ERR(plane))
+		return plane;
 
 	drm_plane_helper_add(plane, &amdgpu_vkms_primary_helper_funcs);
 
Signature · 1 line
2.25.1