From: Wang YanQing <udknight@gmail.com>
To: airlied@linux.ie
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 3/5] drm:drm_platform: fix resource leak in drm_get_platform_dev
Date: Thu, 31 Oct 2013 07:10:24 +0800 [thread overview]
Message-ID: <20131030231023.GA5719@udknight> (raw)
We should call drm_cleanup_in_dev in error handle
code path after drm_fill_in_dev had been called,
or it will cause resource leak heavily, vmalloc
leak etc.
This patch also add call to dev->unload in error
handle code path.
Signed-off-by: Wang YanQing <udknight@gmail.com>
---
drivers/gpu/drm/drm_platform.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index b8a282e..1198fa4 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -66,17 +66,17 @@ int drm_get_platform_dev(struct platform_device *platdev,
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
if (ret)
- goto err_g1;
+ goto err_g2;
}
ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY);
if (ret)
- goto err_g2;
+ goto err_g3;
if (dev->driver->load) {
ret = dev->driver->load(dev, 0);
if (ret)
- goto err_g3;
+ goto err_g4;
}
/* setup the grouping for the legacy output */
@@ -84,7 +84,7 @@ int drm_get_platform_dev(struct platform_device *platdev,
ret = drm_mode_group_init_legacy_group(dev,
&dev->primary->mode_group);
if (ret)
- goto err_g3;
+ goto err_g5;
}
list_add_tail(&dev->driver_item, &driver->device_list);
@@ -96,12 +96,16 @@ int drm_get_platform_dev(struct platform_device *platdev,
driver->date, dev->primary->index);
return 0;
-
-err_g3:
+err_g5:
+ if (dev->driver->unload)
+ dev->driver->unload(dev);
+err_g4:
drm_put_minor(&dev->primary);
-err_g2:
+err_g3:
if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_put_minor(&dev->control);
+err_g2:
+ drm_cleanup_in_dev(dev);
err_g1:
kfree(dev);
mutex_unlock(&drm_global_mutex);
--
1.7.12.4.dirty
reply other threads:[~2013-10-30 23:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131030231023.GA5719@udknight \
--to=udknight@gmail.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).