From patchwork Sat Jun 22 00:02:48 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: 2765091 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 845099F39E for ; Sat, 22 Jun 2013 00:03:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A530E201A8 for ; Sat, 22 Jun 2013 00:03:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C137F201A1 for ; Sat, 22 Jun 2013 00:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161602Ab3FVADq (ORCPT ); Fri, 21 Jun 2013 20:03:46 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:58403 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161521Ab3FVADo (ORCPT ); Fri, 21 Jun 2013 20:03:44 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5M02pg8011680; Fri, 21 Jun 2013 19:02:51 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5M02pbh019557; Fri, 21 Jun 2013 19:02:51 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Fri, 21 Jun 2013 19:02:50 -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 r5M02m0D029819; Fri, 21 Jun 2013 19:02:50 -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 CC: Devicetree Discuss , Linux OMAP List , Linux ARM Kernel List , Linux DaVinci Kernel List , Linux Kernel Mailing List , Linux Documentation List , Linux MMC List , Linux SPI Devel List , Arnd Bergmann , Sekhar Nori , Joel A Fernandes Subject: [PATCH] ARM: common: edma: Fix dangling pointer dereference Date: Fri, 21 Jun 2013 19:02:48 -0500 Message-ID: <1371859368-16063-1-git-send-email-joelagnel@ti.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 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. Seen on linux-davinci/soc-v2 branch. Cc: Sekhar Nori Signed-off-by: Joel A Fernandes --- arch/arm/common/edma.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 2b591b1..f913e82 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,7 @@ static int edma_probe(struct platform_device *pdev) int ret; if (node) { - info = edma_setup_info_from_dt(dev, node); + ninfo[0] = edma_setup_info_from_dt(dev, node); if (IS_ERR(info)) { dev_err(dev, "failed to get DT data\n"); return PTR_ERR(info);