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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 15 May 2013 12:47:03 +0800
From:	Libo Chen <clbchenlibo.chen@...wei.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] msm: iommu: fix leak and invalid access


This patch merge two patch that I sended before:
1. msm: iommu: add missing platform_device_unregister() in err case
2. msm: iommu: no need kfree before kzalloc successful

It fixes two obvious problems:
1. We have registered msm_iommu_driver first, and need unregister it when
registered msm_iommu_ctx_driver fail

2. We don`t need to kfree drvdata before kzalloc successful

Signed-off-by: Libo Chen <libo.chen@...wei.com>
---
 drivers/iommu/msm_iommu_dev.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 8e8fb07..bae0b23 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -292,22 +292,20 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
 	struct msm_iommu_ctx_drvdata *ctx_drvdata = NULL;
 	int i, ret;
 	if (!c || !pdev->dev.parent) {
-		ret = -EINVAL;
-		goto fail;
+		return -EINVAL;
 	}

 	drvdata = dev_get_drvdata(pdev->dev.parent);

 	if (!drvdata) {
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}

 	ctx_drvdata = kzalloc(sizeof(*ctx_drvdata), GFP_KERNEL);
 	if (!ctx_drvdata) {
-		ret = -ENOMEM;
-		goto fail;
+		return -ENOMEM;
 	}
+
 	ctx_drvdata->num = c->num;
 	ctx_drvdata->pdev = pdev;

@@ -401,6 +399,7 @@ static int __init msm_iommu_driver_init(void)

 	ret = platform_driver_register(&msm_iommu_ctx_driver);
 	if (ret != 0) {
+		platform_driver_unregister(&msm_iommu_driver);
 		pr_err("Failed to register IOMMU context driver\n");
 		goto error;
 	}
-- 
1.7.1


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