From: Andrew Morton <akpm@linux-foundation.org>
To: Libo Chen <clbchenlibo.chen@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] msm: iommu: fix leak and invalid access
Date: Thu, 23 May 2013 16:26:32 -0700 [thread overview]
Message-ID: <20130523162632.8a51569b776134b2db32a64e@linux-foundation.org> (raw)
In-Reply-To: <51931347.7020600@huawei.com>
On Wed, 15 May 2013 12:47:03 +0800 Libo Chen <clbchenlibo.chen@huawei.com> wrote:
> It fixes two obvious problems:
> 1. We have registered msm_iommu_driver first, and need unregister it when
> registered msm_iommu_ctx_driver fail
yup, that's a bug.
> 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 <akpm@linux-foundation.org>
Subject: drivers-iommu-msm_iommu_devc-fix-leak-and-invalid-access-fix
remove now-unneeded initialization of ctx_drvdata, remove unneeded braces
Cc: David Brown <davidb@codeaurora.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Libo Chen <clbchenlibo.chen@huawei.com>
Cc: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/iommu/msm_iommu_dev.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff -puN drivers/iommu/msm_iommu_dev.c~drivers-iommu-msm_iommu_devc-fix-leak-and-invalid-access-fix drivers/iommu/msm_iommu_dev.c
--- a/drivers/iommu/msm_iommu_dev.c~drivers-iommu-msm_iommu_devc-fix-leak-and-invalid-access-fix
+++ a/drivers/iommu/msm_iommu_dev.c
@@ -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;
_
prev parent reply other threads:[~2013-05-23 23:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 4:47 Libo Chen
2013-05-22 5:58 ` Libo Chen
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 [this message]
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=20130523162632.8a51569b776134b2db32a64e@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=clbchenlibo.chen@huawei.com \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome