From patchwork Thu Sep 1 09:52:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Gang X-Patchwork-Id: 112903 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 5A86EB745C for ; Thu, 1 Sep 2011 22:46:24 +1000 (EST) Received: from TX2EHSOBE003.bigfish.com (tx2ehsobe002.messaging.microsoft.com [65.55.88.12]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 9CCCDB6F70 for ; Thu, 1 Sep 2011 19:56:26 +1000 (EST) Received: from mail46-tx2-R.bigfish.com (10.9.14.253) by TX2EHSOBE003.bigfish.com (10.9.40.23) with Microsoft SMTP Server id 14.1.225.22; Thu, 1 Sep 2011 09:56:21 +0000 Received: from mail46-tx2 (localhost.localdomain [127.0.0.1]) by mail46-tx2-R.bigfish.com (Postfix) with ESMTP id 60983EC0560; Thu, 1 Sep 2011 09:56:21 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail46-tx2 (localhost.localdomain [127.0.0.1]) by mail46-tx2 (MessageSwitch) id 1314870936901374_28307; Thu, 1 Sep 2011 09:55:36 +0000 (UTC) Received: from TX2EHSMHS031.bigfish.com (unknown [10.9.14.252]) by mail46-tx2.bigfish.com (Postfix) with ESMTP id B462A16480A3; Thu, 1 Sep 2011 09:53:04 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS031.bigfish.com (10.9.99.131) with Microsoft SMTP Server (TLS) id 14.1.225.22; Thu, 1 Sep 2011 09:53:01 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.323.2; Thu, 1 Sep 2011 04:53:00 -0500 Received: from 10.ap.freescale.net (10.ap.freescale.net [10.192.208.115]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p819qvvD025140; Thu, 1 Sep 2011 04:52:59 -0500 (CDT) Received: from 10.ap.freescale.net (localhost.localdomain [127.0.0.1]) by 10.ap.freescale.net (8.13.8/8.13.8) with ESMTP id p819qVUW027357; Thu, 1 Sep 2011 17:52:31 +0800 Received: (from mylinux@localhost) by 10.ap.freescale.net (8.13.8/8.13.8/Submit) id p819qUDs027356; Thu, 1 Sep 2011 17:52:30 +0800 From: Liu Gang To: 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 Message-ID: <1314870744-27325-1-git-send-email-Gang.Liu@freescale.com> X-Mailer: git-send-email 1.7.3.1 MIME-Version: 1.0 X-OriginatorOrg: freescale.net X-Mailman-Approved-At: Thu, 01 Sep 2011 22:46:14 +1000 Cc: r58472@freescale.com, r61911@freescale.com, linux-kernel@vger.kernel.org, Liu Gang , akpm@linux-foundation.org, B11780@freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org 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 --- 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: