From patchwork Sun Mar 30 08:42:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3909701 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B2ECBF540 for ; Sun, 30 Mar 2014 08:43:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BB4720383 for ; Sun, 30 Mar 2014 08:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EC2320384 for ; Sun, 30 Mar 2014 08:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752612AbaC3InO (ORCPT ); Sun, 30 Mar 2014 04:43:14 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:52968 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752005AbaC3InN (ORCPT ); Sun, 30 Mar 2014 04:43:13 -0400 Received: by mail-pd0-f174.google.com with SMTP id y13so6690295pdi.33 for ; Sun, 30 Mar 2014 01:43:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=LHem6T+OuBXDpLLDjjFufzU1wtX+NbjQDf8lCu89hXQ=; b=KxwH3uO7CsxmZHsWy2xuzFx9X+SAbF57w9tALYkM7wxsotWymZLm7N7flWlY3uBsYS X8ZO0qIFXcKdyPMtlVT1qr0H9rNS4K3CvC5pZnzKQdtwBerf5WBFpwhKvXBk7tG4fJdj mqHCgQRlogBeagcymKwDYx6ccIG5vU5f9eEGxsoyj7xGdbTfjxFa+g8RiD2frOfuTu+A ly/39hP+qfZ2n6wJiRIZGuWQ1YM7FblTSqaRLxH3K9eyjibO869rIYVYuCt8Dml41aOw DsTYl3/DUaxuhVT1+cQiDKL8GJ90l5tW+f1sobXO8bxjk+b2ChbkmHFOtsTAru/Bf9Yp BZdg== X-Gm-Message-State: ALoCoQk5h+tpqxABikoeyMBIOlAPTsdcb58+qkSUQsQCMofehko+AKI1a5hbhE8AkvQIK5yyeW6Q X-Received: by 10.66.155.7 with SMTP id vs7mr18273934pab.42.1396168992639; Sun, 30 Mar 2014 01:43:12 -0700 (PDT) Received: from [192.168.0.119] (59-115-21-222.dynamic.hinet.net. [59.115.21.222]) by mx.google.com with ESMTPSA id g6sm22938693pat.2.2014.03.30.01.43.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 30 Mar 2014 01:43:11 -0700 (PDT) Message-ID: <1396168977.21905.6.camel@phoenix> Subject: [PATCH] spi: fsl-spi: Fix memory leak From: Axel Lin To: Mark Brown Cc: Hou Zhiqiang , Sebastian Andrzej Siewior , linux-spi@vger.kernel.org Date: Sun, 30 Mar 2014 16:42:57 +0800 X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 mpc8xxx_spi_probe() has set master->cleanup = mpc8xxx_spi_cleanup, however current code overrides the setting in fsl_spi_probe() and set master->cleanup = fsl_spi_cleanup. Thus the memory allocated for cs is not freed anywhere. Convert to use devm_kzalloc to fix the memory leak. Signed-off-by: Axel Lin --- drivers/spi/spi-fsl-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index f35488e..9effb91 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -430,7 +430,7 @@ static int fsl_spi_setup(struct spi_device *spi) return -EINVAL; if (!cs) { - cs = kzalloc(sizeof *cs, GFP_KERNEL); + cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; spi->controller_state = cs;