]> git.karo-electronics.de Git - karo-tx-linux.git/commit
arch/powerpc/sysdev/fsl_rio.c: release rapidio port I/O region resource if port faile...
authorLiu Gang <Gang.Liu@freescale.com>
Mon, 24 Oct 2011 15:00:08 +0000 (02:00 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 25 Oct 2011 09:08:19 +0000 (20:08 +1100)
commitd04e9814a0ecd298c53a638d0bcac0c2a0dde736
tree5df3f50e03cc809ef8194c49d77e819e55cc0809
parentc7a1fb34c64832b4aece8237623be979a95e2d17
arch/powerpc/sysdev/fsl_rio.c: release rapidio port I/O region resource if port failed to initialize

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>
Acked-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/powerpc/sysdev/fsl_rio.c