dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/5] drm:drm_usb: fix resource leak in drm_get_usb_dev
@ 2013-10-30 23:11 Wang YanQing
  0 siblings, 0 replies; only message in thread
From: Wang YanQing @ 2013-10-30 23:11 UTC (permalink / raw)
  To: airlied; +Cc: linux-kernel, dri-devel

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_usb.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index 34a156f..7e4de60 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -31,23 +31,23 @@ int drm_get_usb_dev(struct usb_interface *interface,
 	usb_set_intfdata(interface, dev);
 	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 */
 	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);
 
@@ -58,11 +58,15 @@ int drm_get_usb_dev(struct usb_interface *interface,
 		 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:
 	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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-10-30 23:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-30 23:11 [PATCH 4/5] drm:drm_usb: fix resource leak in drm_get_usb_dev Wang YanQing

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).