diff mbox

[08/14] drm/mgag200: Cleanup cursor BOs properly

Message ID 20170718144320.8354-9-tiwai@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Iwai July 18, 2017, 2:43 p.m. UTC
From: Egbert Eich <eich@suse.de>

Cursor BOs should be cleaned up properly on error or when unloading
the driver.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/mgag200/mgag200_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 87c5469d06a7..73614154a5ef 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -354,9 +354,12 @@  int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
 	/* Make small buffers to store a hardware cursor (double buffered icon updates) */
 	mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
 					  &mdev->cursor.pixels_1);
-	mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
-					  &mdev->cursor.pixels_2);
+	if (mdev->cursor.pixels_1)
+		mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
+				  &mdev->cursor.pixels_2);
 	if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1) {
+		if (mdev->cursor.pixels_1)
+			drm_gem_object_unreference_unlocked(&mdev->cursor.pixels_1->gem);
 		mdev->cursor.pixels_1 = NULL;
 		mdev->cursor.pixels_2 = NULL;
 		dev_warn(&dev->pdev->dev,
@@ -384,6 +387,10 @@  void mgag200_driver_unload(struct drm_device *dev)
 	if (mdev == NULL)
 		return;
 	mgag200_modeset_fini(mdev);
+	if (mdev->cursor.pixels_1)
+		drm_gem_object_unreference_unlocked(&mdev->cursor.pixels_1->gem);
+	if (mdev->cursor.pixels_2)
+		drm_gem_object_unreference_unlocked(&mdev->cursor.pixels_2->gem);
 	mgag200_fbdev_fini(mdev);
 	drm_mode_config_cleanup(dev);
 	mgag200_mm_fini(mdev);