From: Liu Gang <Gang.Liu@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: r58472@freescale.com, r61911@freescale.com,
linux-kernel@vger.kernel.org, Liu Gang <Gang.Liu@freescale.com>,
akpm@linux-foundation.org, B11780@freescale.com
Subject: [PATCH] fsl-rio: Release rapidio port I/O region resource if port failed to initialize
Date: Thu, 1 Sep 2011 17:52:24 +0800 [thread overview]
Message-ID: <1314870744-27325-1-git-send-email-Gang.Liu@freescale.com> (raw)
The "struct rio_mport" contains a member of master port I/O memory resource structure
"struct resource iores". This resource will be read from device tree and be used for
rapidio R/W transaction memory space. Rapidio requests the port I/O memory resource
under the root resource "iomem_resource".
struct rio_mport *port;
port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
request_resource(&iomem_resource, &port->iores);
When port failed to initialize, allocated "rio_mport" structure memory will be freed,
and the port I/O memory resource structure pointer "&port->iores" will be invalid. If
other requests resource under "iomem_resource", "&port->iores" node may be operated in
the child resources list and this will cause the system to crash.
So the requested port I/O memory resource should be released before freeing allocated
"rio_mport" structure.
Signed-off-by: Liu Gang <Gang.Liu@freescale.com>
---
arch/powerpc/sysdev/fsl_rio.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index c65f75a..22ffccd 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1608,6 +1608,7 @@ int fsl_rio_setup(struct platform_device *dev)
return 0;
err:
iounmap(priv->regs_win);
+ release_resource(&port->iores);
err_res:
kfree(priv);
err_priv:
--
1.7.3.1
next reply other threads:[~2011-09-01 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-01 9:52 Liu Gang [this message]
2011-09-01 13:29 ` [PATCH] fsl-rio: Release rapidio port I/O region resource if portfailed to initialize Bounine, Alexandre
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=1314870744-27325-1-git-send-email-Gang.Liu@freescale.com \
--to=gang.liu@freescale.com \
--cc=B11780@freescale.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=r58472@freescale.com \
--cc=r61911@freescale.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