Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2925957rwb; Mon, 15 Aug 2022 14:11:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QHwUcStZYMKOz7NwfhAI2NFPlIBRWjuTnV0RK9gwpom5xvwOCfPujOyh5Nt1weKXOEHK6 X-Received: by 2002:a05:6402:43c5:b0:43d:f9ca:4061 with SMTP id p5-20020a05640243c500b0043df9ca4061mr16175919edc.352.1660597863824; Mon, 15 Aug 2022 14:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597863; cv=none; d=google.com; s=arc-20160816; b=dxh/nc4X3Hl7C5o45hN5b95zRce4ZJUhmR0GHcwU1CXfoe/cnRPZUx0VVEwbb705Zt GY25KjxDjcQu/8JYCz5g9oODkROisthiNRccdRKhL2tNiAh6vtMNc0uKkPN+Vgbpor23 VMSWkEj67m/ctvdK91YjreEjua1pA3YjnpalJihay2xv95y5fJeodf7YLZxMqZ3gQoPx CXQr7KYPpdUNKtQuS5EncRd4XUMLXhZr0s7IQbCQvGISLFa+JrpFU+FkXrTQigbUAOpj FVh4FFaXKLNd7aU4/m0CdtOlI2aSCR4iqKuehphMhBgX6JO2KIKsmjEpuAX9tqbub77i xJRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LU9qXv6nyh0nPleinDIWHRknDbkfZ4Spt/PLLHWJNq4=; b=AroSbHCCG37IVIr5YkIxuby30SHRNQB9jL2kfK2HHSJcSyYmt0dnkIlvVgfgkGAhLg zrFJig2vxlrxNkYW3Ko/hAV5Wr0p0QJ9nVq1A6l2oCw41c68iStg5Z6ATXu6IfNtF7f3 p0KkzcqnW4P4ObBC2aRZCl79I3G1aV5FYRb/N2dWbNHfhqsI9VylFlvAqLzRRmA3yUwg xmC8AhSZ1ekXJ5pMPtEoVUdTpcIHkASyxnDLMAYF25VE55SGIfp6fT0l9XLx4KfOFHPz ryQtfpQTg+GbeT0dJvxuADRt2D2ZdajnE69ZTLB8Rci9tQv/JL8cb/ivop51lvR7SfQn BKXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PanmB8ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq37-20020a1709073f2500b00731201adfc1si8890839ejc.713.2022.08.15.14.10.37; Mon, 15 Aug 2022 14:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PanmB8ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343618AbiHOTJS (ORCPT + 99 others); Mon, 15 Aug 2022 15:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245730AbiHOTGK (ORCPT ); Mon, 15 Aug 2022 15:06:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 122942CDD7; Mon, 15 Aug 2022 11:34:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A3D7D6105C; Mon, 15 Aug 2022 18:34:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D8CAC433C1; Mon, 15 Aug 2022 18:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588489; bh=JDV9LBwF5joWK8HGi4wBwjEykNxNVY96ePmNBMJjcug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PanmB8eaXtt/yJVlCZRVxWagEdwhHo+HOVYMzbb4QbIf5FUC1xe+grFWQku3bF1VG M3Gy1JXvg+Ucfrb9MN0vimUiAOzQg6VR+79L8DTPmlnTyl9cEgpPbK9C+Xh+YTV5kn Qvd9V4bD311QgunN+OiL7JP8f1TgRWS5RFLxiWHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Liang Yang , Miquel Raynal , Sasha Levin Subject: [PATCH 5.15 392/779] mtd: rawnand: meson: Fix a potential double free issue Date: Mon, 15 Aug 2022 20:00:36 +0200 Message-Id: <20220815180354.051787381@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit ec0da06337751b18f6dee06b6526e0f0d6e80369 ] 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 Acked-by: Liang Yang Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/ec15c358b8063f7c50ff4cd628cf0d2e14e43f49.1653064877.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- 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); } -- 2.35.1