From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14256C433EF for ; Thu, 26 May 2022 05:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345673AbiEZFgP (ORCPT ); Thu, 26 May 2022 01:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239996AbiEZFgL (ORCPT ); Thu, 26 May 2022 01:36:11 -0400 Received: from mail-sz.amlogic.com (mail-sz.amlogic.com [211.162.65.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8A7E097; Wed, 25 May 2022 22:36:08 -0700 (PDT) Received: from [10.28.39.121] (10.28.39.121) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 26 May 2022 13:34:46 +0800 Message-ID: Date: Thu, 26 May 2022 13:34:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] mtd: rawnand: meson: Fix a potential double free issue Content-Language: en-US To: Christophe JAILLET , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yixun Lan , Jianxin Pan CC: , , , , References: From: Liang Yang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.28.39.121] X-ClientProxiedBy: mail-sz.amlogic.com (10.28.11.5) To mail-sz.amlogic.com (10.28.11.5) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christophe, On 2022/5/21 0:41, Christophe JAILLET wrote: > [ EXTERNAL EMAIL ] > > When meson_nfc_nand_chip_cleanup() is called, it will call: > meson_nfc_free_buffer(&meson_chip->nand); > nand_cleanup(&meson_chip->nand); > > nand_cleanup() in turn will call nand_detach() which calls the > .detach_chip() which is here meson_nand_detach_chip(). > > meson_nand_detach_chip() already calls meson_nfc_free_buffer(), so we > could double free some memory. > > Fix it by removing the unneeded explicit call to meson_nfc_free_buffer(). > > Fixes: 8fae856c5350 ("mtd: rawnand: meson: add support for Amlogic NAND flash controller") > Signed-off-by: Christophe JAILLET > --- > This patch is speculative, so review with care. > --- > drivers/mtd/nand/raw/meson_nand.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c > index ac3be92872d0..032180183339 100644 > --- a/drivers/mtd/nand/raw/meson_nand.c > +++ b/drivers/mtd/nand/raw/meson_nand.c > @@ -1307,7 +1307,6 @@ static int meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc) > if (ret) > return ret; > > - meson_nfc_free_buffer(&meson_chip->nand); > nand_cleanup(&meson_chip->nand); > list_del(&meson_chip->node); > } Acked-by: Liang Yang Thanks, Liang