msm: iommu: fix leak and invalid access
Subsystems (3)
PATCH 1/1 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
--- drivers/iommu/msm_iommu_dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
drivers/iommu/msm_iommu_dev.c +5 -6
@@ -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; }
Signature · 1 line
1.7.1
ping...
Quoted 56 lines · Libo Chen
This patch merge two patch that I sended before:
1. msm: iommu: add missingplatform_device_unregister()in err case
2. msm: iommu: no need kfree before kzalloc successfulIt fixes two obvious problems:
1. We have registeredmsm_iommu_driverfirst, and need unregister it when registeredmsm_iommu_ctx_driverfail2. We don`t need to kfree drvdata before kzalloc successful
Signed-off-by Libo Chen <[email protected]>--- drivers/iommu/msm_iommu_dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)drivers/iommu/msm_iommu_dev.c +5
-6@@ -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; }
Quoted 1 line · Libo Chen
ping...
This is the first I've seen this patch. The original appears to have been sent to Andrew Morton and lkml. I'll reply with an Ack there.
David
Signature · 3 lines
sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 8 lines · Libo Chen
This patch merge two patch that I sended before:
1. msm: iommu: add missingplatform_device_unregister()in err case
2. msm: iommu: no need kfree before kzalloc successfulIt fixes two obvious problems:
1. We have registeredmsm_iommu_driverfirst, and need unregister it when registeredmsm_iommu_ctx_driverfail
Quoted 6 lines
2. We don`t need to kfree drvdata before kzalloc successful
Signed-off-by Libo Chen <[email protected]>--- drivers/iommu/msm_iommu_dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
Signature · 3 lines
sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 7 lines · David Brown
Quoted 1 line · Libo Chen
Quoted 1 line
ping...
This is the first I've seen this patch. The original appears to have been sent to Andrew Morton and lkml. I'll reply with an Ack there.
David
Regards
Libo
Quoted 3 lines · On Wed, 15 May 2013 12:47:03 +0800 Libo Chen <[email protected]>…
It fixes two obvious problems:
1. We have registeredmsm_iommu_driverfirst, and need unregister it when registeredmsm_iommu_ctx_driverfail
yup, that's a bug.
Quoted 1 line
2. We don`t need to kfree drvdata before kzalloc successful
The code's OK at present - kfree(NULL) is legal.
However I suppose the patch cleans things up a little bit, however it missed a couple of things:
From: Andrew Morton <[email protected]>
Subject: drivers-iommu-msm_iommu_devc-fix-leak-and-invalid-access-fix
remove now-unneeded initialization of ctx_drvdata, remove unneeded braces
---
drivers/iommu/msm_iommu_dev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/iommu/msm_iommu_dev.c renamed from drivers/iommu/msm_iommu_dev.c~drivers-iommu-msm_iommu_devc-fix-leak-and-invalid-access-fix +5 -8
@@ -289,22 +289,19 @@ static int msm_iommu_ctx_probe(struct pl {struct msm_iommu_ctx_dev *c = pdev->dev.platform_data;struct msm_iommu_drvdata *drvdata; -struct msm_iommu_ctx_drvdata *ctx_drvdata =NULL ; +struct msm_iommu_ctx_drvdata *ctx_drvdata;int i, ret; -if (!c || !pdev->dev.parent) { + +if (!c || !pdev->dev.parent)return -EINVAL ; - } drvdata =dev_get_drvdata (pdev->dev.parent); - -if (!drvdata) { +if (!drvdata)return -ENODEV ; - } ctx_drvdata =kzalloc (sizeof (*ctx_drvdata),GFP_KERNEL ); -if (!ctx_drvdata) { +if (!ctx_drvdata)return -ENOMEM ; - } ctx_drvdata->num = c->num; ctx_drvdata->pdev = pdev;
_
Joerg Roedel
maintainerQuoted 9 lines · Libo Chen
Quoted 9 lines
This patch merge two patch that I sended before:
1. msm: iommu: add missingplatform_device_unregister()in err case
2. msm: iommu: no need kfree before kzalloc successfulIt fixes two obvious problems:
1. We have registeredmsm_iommu_driverfirst, and need unregister it when registeredmsm_iommu_ctx_driverfail
Quoted 6 lines
Quoted 6 lines
2. We don`t need to kfree drvdata before kzalloc successful
Signed-off-by Libo Chen <[email protected]>--- drivers/iommu/msm_iommu_dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
Has this patch already been handled? If not please resend it to me and I will take care of it.
Joerg
Quoted 12 lines · Joerg Roedel
Quoted 11 lines · Libo Chen
Quoted 11 lines
This patch merge two patch that I sended before:
1. msm: iommu: add missingplatform_device_unregister()in err case
2. msm: iommu: no need kfree before kzalloc successfulIt fixes two obvious problems:
1. We have registeredmsm_iommu_driverfirst, and need unregister it when registeredmsm_iommu_ctx_driverfail2. We don`t need to kfree drvdata before kzalloc successful
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Libo Chen <[email protected]>--- drivers/iommu/msm_iommu_dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)Has this patch already been handled? If not please resend it to me and I will take care of it.
It should be included to -mm tree by Andrew Morton
Regards,
Libo
Quoted 11 lines
Joerg
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/.