From patchwork Thu Aug 28 08:53:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4801041 Return-Path: X-Original-To: patchwork-linux-spi@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 BD9169F666 for ; Thu, 28 Aug 2014 08:53:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F131C2012E for ; Thu, 28 Aug 2014 08:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2007A2015A for ; Thu, 28 Aug 2014 08:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936338AbaH1Ixq (ORCPT ); Thu, 28 Aug 2014 04:53:46 -0400 Received: from mga09.intel.com ([134.134.136.24]:11885 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936319AbaH1Ixp (ORCPT ); Thu, 28 Aug 2014 04:53:45 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by orsmga102.jf.intel.com with ESMTP; 28 Aug 2014 01:47:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,416,1406617200"; d="scan'208";a="473438865" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.168]) by azsmga001.ch.intel.com with ESMTP; 28 Aug 2014 01:53:19 -0700 Received: from andy by smile with local (Exim 4.84) (envelope-from ) id 1XMvSI-0006nN-VM; Thu, 28 Aug 2014 11:53:18 +0300 From: Andy Shevchenko To: Feng Tang , Mark Brown , linux-spi@vger.kernel.org Cc: Andy Shevchenko , Subject: [PATCH] spi: dw-mid: don't leak memory on exit Date: Thu, 28 Aug 2014 11:53:17 +0300 Message-Id: <1409215997-26085-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 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 When built with DMA support the memory for an internal structure is allocated but not freed. Converting to devm_kzalloc solves the issue. Fixes: 7063c0d942a1 (spi/dw_spi: add DMA support) Signed-off-by: Andy Shevchenko Cc: # v2.6.38+ --- drivers/spi/spi-dw-mid.c | 4 ++-- drivers/spi/spi-dw-pci.c | 5 ++--- drivers/spi/spi-dw.h | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c index c79bf96..ceb95b4 100644 --- a/drivers/spi/spi-dw-mid.c +++ b/drivers/spi/spi-dw-mid.c @@ -202,7 +202,7 @@ static struct dw_spi_dma_ops mid_dma_ops = { #define CLK_SPI_CDIV_MASK 0x00000e00 #define CLK_SPI_DISABLE_OFFSET 8 -int dw_spi_mid_init(struct dw_spi *dws) +int dw_spi_mid_init(struct device *dev, struct dw_spi *dws) { void __iomem *clk_reg; u32 clk_cdiv; @@ -220,7 +220,7 @@ int dw_spi_mid_init(struct dw_spi *dws) dws->fifo_len = 40; /* FIFO has 40 words buffer */ #ifdef CONFIG_SPI_DW_MID_DMA - dws->dma_priv = kzalloc(sizeof(struct mid_dma), GFP_KERNEL); + dws->dma_priv = devm_kzalloc(dev, sizeof(struct mid_dma), GFP_KERNEL); if (!dws->dma_priv) return -ENOMEM; dws->dma_ops = &mid_dma_ops; diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c index b8b02d7..dd06c07 100644 --- a/drivers/spi/spi-dw-pci.c +++ b/drivers/spi/spi-dw-pci.c @@ -28,8 +28,7 @@ struct dw_spi_pci { struct dw_spi dws; }; -static int spi_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct dw_spi_pci *dwpci; struct dw_spi *dws; @@ -66,7 +65,7 @@ static int spi_pci_probe(struct pci_dev *pdev, * clock rate, FIFO depth. */ if (pdev->device == 0x0800) { - ret = dw_spi_mid_init(dws); + ret = dw_spi_mid_init(&pdev->dev, dws); if (ret) return ret; } diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 0f8cece..b3ff9eb 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -232,5 +232,6 @@ extern int dw_spi_resume_host(struct dw_spi *dws); extern void dw_spi_xfer_done(struct dw_spi *dws); /* platform related setup */ -extern int dw_spi_mid_init(struct dw_spi *dws); /* Intel MID platforms */ +/* Intel MID platforms */ +extern int dw_spi_mid_init(struct device *dev, struct dw_spi *dws); #endif /* DW_SPI_HEADER_H */