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: 232282 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id C01FF2C0154 for ; Fri, 29 Mar 2013 15:29:27 +1100 (EST) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 85FE32C00AF for ; Fri, 29 Mar 2013 15:29:00 +1100 (EST) Received: by mail-vc0-f169.google.com with SMTP id kw10so219815vcb.28 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 Cc: linuxppc-dev@lists.ozlabs.org, Li Hao , linux-mtd@lists.infradead.org, scottwood@freescale.com, dwmw2@infradead.org, Cao Yonghua X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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; }