lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20131030230914.GA5697@udknight>
Date:	Thu, 31 Oct 2013 07:09:17 +0800
From:	Wang YanQing <udknight@...il.com>
To:	airlied@...ux.ie
Cc:	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/5] drm:drm_pci: fix resource leak in drm_get_pci_dev

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@...il.com>
---
 drivers/gpu/drm/drm_pci.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 14194b6..5f15805 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -345,16 +345,16 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 		pci_set_drvdata(pdev, dev);
 		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
 		if (ret)
-			goto err_g2;
+			goto err_g3;
 	}
 
 	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
-		goto err_g3;
+		goto err_g4;
 
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, ent->driver_data);
 		if (ret)
-			goto err_g4;
+			goto err_g5;
 	}
 
 	/* setup the grouping for the legacy output */
@@ -362,7 +362,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 		ret = drm_mode_group_init_legacy_group(dev,
 						&dev->primary->mode_group);
 		if (ret)
-			goto err_g4;
+			goto err_g6;
 	}
 
 	list_add_tail(&dev->driver_item, &driver->device_list);
@@ -373,12 +373,16 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 
 	mutex_unlock(&drm_global_mutex);
 	return 0;
-
-err_g4:
+err_g6:
+	if (dev->driver->unload)
+		dev->driver->unload(dev);
+err_g5:
 	drm_put_minor(&dev->primary);
-err_g3:
+err_g4:
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_put_minor(&dev->control);
+err_g3:
+	drm_cleanup_in_dev(dev);
 err_g2:
 	pci_disable_device(pdev);
 err_g1:
-- 
1.7.12.4.dirty
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ