From: Libo Chen <clbchenlibo.chen@huawei.com>
To: <ohad@wizery.com>, <joerg.roedel@amd.com>, <davidb@codeaurora.org>
Cc: LKML <linux-kernel@vger.kernel.org>, <joro@8bytes.org>,
<Varun.Sethi@freescale.com>, <iommu@lists.linux-foundation.org>,
<mingo@kernel.org>, <ddutile@redhat.com>
Subject: Re: [PATCH] msm: iommu: fix leak and invalid access
Date: Wed, 22 May 2013 13:58:39 +0800 [thread overview]
Message-ID: <519C5E8F.7060006@huawei.com> (raw)
In-Reply-To: <51931347.7020600@huawei.com>
ping...
On 2013/5/15 12:47, Libo Chen wrote:
>
> 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@huawei.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;
> }
>
next prev parent reply other threads:[~2013-05-22 5:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 4:47 [PATCH] msm: iommu: fix leak and invalid access Libo Chen
2013-05-22 5:58 ` Libo Chen [this message]
2013-05-22 22:29 ` David Brown
2013-05-23 1:23 ` Libo Chen
2013-05-28 12:27 ` Joerg Roedel
2013-05-28 12:37 ` Libo Chen
2013-05-22 22:30 ` David Brown
2013-05-23 23:26 ` Andrew Morton
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=519C5E8F.7060006@huawei.com \
--to=clbchenlibo.chen@huawei.com \
--cc=Varun.Sethi@freescale.com \
--cc=davidb@codeaurora.org \
--cc=ddutile@redhat.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joerg.roedel@amd.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=ohad@wizery.com \
/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