From patchwork Fri Mar 29 04:28:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 232283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 001162C00BD for ; Fri, 29 Mar 2013 15:30:23 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ULQw2-0006Xp-Jl; Fri, 29 Mar 2013 04:29:02 +0000 Received: from mail-ve0-f171.google.com ([209.85.128.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ULQvy-0006XF-LD for linux-mtd@lists.infradead.org; Fri, 29 Mar 2013 04:28:59 +0000 Received: by mail-ve0-f171.google.com with SMTP id b10so238436vea.30 for ; Thu, 28 Mar 2013 21:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=7qVNSM+vW26qg3V1UutUqcXJCN4hUyJVjJRIoKTL7VA=; b=jCtLXnQclt3HFVxeOinNvkO7c4Xt/JkyjFtrXPWwvuru/lDl++/vF7UrN6DDJwDljp n6nlgIEGqayWgnFoIqS+MSmJKxWnu7vN4rhVwdeh/Xfa3A+BrWSnqQ0AVWsRx9pO22j0 inAR7JuP+qlIOqFLEXGHaW/tJfNaQ9SfuP4gdBIcIuRb+D3AveEYlzmMHINFOpM9c/m3 w1bBkAvyPE9a5Bof6acrFPPByoy0ywvw/4jWXNWp5TOioh5hNt76/jTb7u1JlGjld6+1 j4PcIHSy4EwXg0jypU3ANauBqy2iBKayy/jvHx9HUa02fDvNN0u9cZSL+kYKR68gVrmN /VFQ== MIME-Version: 1.0 X-Received: by 10.52.32.230 with SMTP id m6mr746981vdi.83.1364531337022; Thu, 28 Mar 2013 21:28:57 -0700 (PDT) Received: by 10.58.22.97 with HTTP; Thu, 28 Mar 2013 21:28:56 -0700 (PDT) In-Reply-To: <1364387100-23013-1-git-send-email-tie-fei.zang@freescale.com> References: <1364387100-23013-1-git-send-email-tie-fei.zang@freescale.com> Date: Thu, 28 Mar 2013 21:28:56 -0700 Message-ID: Subject: Re: [upstream] mtd/ifc: fix ifc driver memory release issue From: Brian Norris To: Roy Zang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130329_002858_771674_8B6D1D44 X-CRM114-Status: GOOD ( 12.57 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.128.171 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linuxppc-dev@lists.ozlabs.org, galak@kernel.crashing.org, Li Hao , linux-mtd@lists.infradead.org, scottwood@freescale.com, dwmw2@infradead.org, Cao Yonghua X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Wed, Mar 27, 2013 at 5:25 AM, Roy Zang wrote: > memory is allocated by devm_kzalloc, so release it using > devm_kfree() instead kfree(); You are correct that it should not be freed with kfree(). But the correct solution is that it does not need to be freed (explicitly) at all. That's the whole point of the managed allocators (i.e., devm_kzalloc()). Try this patch instead. Totally untested here. From: Brian Norris Date: Thu, 28 Mar 2013 21:20:27 -0700 Subject: [PATCH] mtd: fsl_ifc_nand: remove incorrect kfree() The struct fsl_ifc_mtd is allocated with devm_kzalloc, so its memory is "managed" automatically by the kernel. That is, we do not need to free it explicitly; it will be freed when the device is removed. And we *certainly* shouldn't free it with a regular kfree(). Signed-off-by: Brian Norris --- drivers/mtd/nand/fsl_ifc_nand.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index f1f7f12..180bfa7 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -908,7 +908,6 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv) ifc_nand_ctrl->chips[priv->bank] = NULL; dev_set_drvdata(priv->dev, NULL); - kfree(priv); return 0; }