From patchwork Sat Jun 22 03:31:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fernandes, Joel A" X-Patchwork-Id: 2765201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (unknown [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AD11FC0AB1 for ; Sat, 22 Jun 2013 03:32:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2E252010E for ; Sat, 22 Jun 2013 03:32:23 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3EEE2010C for ; Sat, 22 Jun 2013 03:32:22 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UqEYd-0001Jc-Dh; Sat, 22 Jun 2013 03:32:11 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UqEYa-0002QJ-SR; Sat, 22 Jun 2013 03:32:08 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UqEYX-0002Pe-TK for linux-arm-kernel@lists.infradead.org; Sat, 22 Jun 2013 03:32:06 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5M3VTBZ028697; Fri, 21 Jun 2013 22:31:29 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5M3VTgd024268; Fri, 21 Jun 2013 22:31:29 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Fri, 21 Jun 2013 22:31:29 -0500 Received: from localhost.localdomain (lta0273324-128247106216.am.dhcp.ti.com [128.247.106.216]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5M3VHgV017316; Fri, 21 Jun 2013 22:31:29 -0500 From: Joel A Fernandes To: Tony Lindgren , Sekhar Nori , Matt Porter , Grant Likely , Rob Herring , Vinod Koul , Mark Brown , Benoit Cousson , Russell King , Rob Landley , Andrew Morton , Jason Kridner , Koen Kooi Subject: [PATCH v2] ARM: common: edma: Fix dangling pointer dereference Date: Fri, 21 Jun 2013 22:31:17 -0500 Message-ID: <1371871877-15269-1-git-send-email-joelagnel@ti.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130621_233206_041486_6376099E X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: -8.4 (--------) Cc: Joel A Fernandes , Linux DaVinci Kernel List , Arnd Bergmann , Linux Documentation List , Devicetree Discuss , Linux MMC List , Linux Kernel Mailing List , Linux SPI Devel List , Linux OMAP List , Linux ARM Kernel List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fixup for linux-davinci/soc-v2 branch. Please ignore v1 and use this. Returning a pointer to a variable in the setup_from_dt function is causing dangling pointer dereferences. This causes boot to fail on AM33XX. Add ninfo to the caller's stack and just return the kzalloc'ed ptr from the calling function. v2: Fixed last issue in davinci branch: ninfo 2D array is used for DT platforms. info is shared between DT and non-DT cases. So point info to ninfo. With this MMC is working (rootfs mount) on AM33XX. Signed-off-by: Sekhar Nori Signed-off-by: Joel A Fernandes --- arch/arm/common/edma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 2b591b1..3567ba1 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -1514,10 +1514,9 @@ static struct of_dma_filter_info edma_filter_info = { .filter_fn = edma_filter_fn, }; -static struct edma_soc_info **edma_setup_info_from_dt(struct device *dev, +static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev, struct device_node *node) { - static struct edma_soc_info **info; struct edma_soc_info *ninfo; int ret; @@ -1539,9 +1538,7 @@ static struct edma_soc_info **edma_setup_info_from_dt(struct device *dev, of_dma_controller_register(dev->of_node, of_dma_simple_xlate, &edma_filter_info); - info = &ninfo; - - return info; + return ninfo; } #else static struct edma_soc_info **edma_setup_info_from_dt(struct device *dev, @@ -1554,6 +1551,7 @@ static struct edma_soc_info **edma_setup_info_from_dt(struct device *dev, static int edma_probe(struct platform_device *pdev) { struct edma_soc_info **info = pdev->dev.platform_data; + struct edma_soc_info *ninfo[EDMA_MAX_CC] = {NULL}; s8 (*queue_priority_mapping)[2]; s8 (*queue_tc_mapping)[2]; int i, j, off, ln, found = 0; @@ -1572,7 +1570,9 @@ static int edma_probe(struct platform_device *pdev) int ret; if (node) { - info = edma_setup_info_from_dt(dev, node); + /* For now, for DT we populate only first ninfo element */ + ninfo[0] = edma_setup_info_from_dt(dev, node); + info = ninfo; if (IS_ERR(info)) { dev_err(dev, "failed to get DT data\n"); return PTR_ERR(info);