Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026001rwb; Mon, 15 Aug 2022 16:24:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5CB0R5gtJgM8tljHsYSYLF1qMnRPeFxXJQmRS4BhuDBbWV/3n+XCsve1NaFEyM8oCYUI0J X-Received: by 2002:a05:6402:2756:b0:443:4a6d:f05a with SMTP id z22-20020a056402275600b004434a6df05amr14480039edd.396.1660605841997; Mon, 15 Aug 2022 16:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605841; cv=none; d=google.com; s=arc-20160816; b=GP+700FiQa+n44/GdVz1hQ9YYv6q3ed3Z655r6tX5Zs3NM6DG+KznJJV4ILsnDrZ8T e6V+mTGJO6kAeClKuOpzobFmKA7+Ggi6Zz8nGDob873R/8SqZd+8CSlDtAyCmTyVvbjS NPeDIpkX/FJdHYEYI8o5wZfbzRIcg3lN0VfTP9FgSDrX3w7Yj0e3+jB6ZzT5MIITYIEy swj3DSDOYz0ehgg/FMnVeZeXcLiQGXBlWUiYddGzVinIL0WezBWhmu0DT4oUZxYo4fPV PDaecdlPYpIg3tr2ZX9kWzA6TCTyI/HjCM+Id/i2wB4WQu5/SOfIJuksV3fGFVvnvMEB f3Nw== 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=idVk2yoFAvwzbOIFX0b1tRnwdCCmRc9bxnXorog/pFsioj3KzxagyowYZVtsWJtA2/ UG6JTof26DaYLJ9swott38TSsZfqZIgPZhmCUmOhsZTBydc0bHASHXuLDiKgHJQlmj6f AMvv4bYJJNguRo8MnKUQZRKRiH4q3gbmkyHRvuXHIw3YVjEc7ShG2E5icynnrcv0JDAD mYcpAoPyE+p4DomYS8MSVRyTfvrNHRomCiXd8rvvs5rZtelbMSdh7PejcHItl6WQZAXB fjE1iC2cZDgO4DAUqIXwuLU8WlE5lM+UB9zSuIforpI27FS28I6nIxzVsbvf4yWuYNPj U93g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wg+yhhq2; 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 z18-20020a05640240d200b0044063348cf7si10147758edb.555.2022.08.15.16.23.37; Mon, 15 Aug 2022 16:24:01 -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=Wg+yhhq2; 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 S243690AbiHOV2W (ORCPT + 99 others); Mon, 15 Aug 2022 17:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243679AbiHOVTw (ORCPT ); Mon, 15 Aug 2022 17:19:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1996DE3C3F; Mon, 15 Aug 2022 12:22:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id E8A79B81062; Mon, 15 Aug 2022 19:22:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35B05C433D6; Mon, 15 Aug 2022 19:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591324; bh=JDV9LBwF5joWK8HGi4wBwjEykNxNVY96ePmNBMJjcug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wg+yhhq2w4AKqu+K+Kh242wNg6Hc9jhmoTY0azcSb3kTGh9qE+SvEudj2PJ/gE4Ks aiYelVkGMeI3QRzv4LZlMcA16ZuFa/SrHdcCrLf4ILXkdfDOSjlwiHbLQ8Mx2/DKs9 JsePeO4C8aMxPZQHfekuFConOHQg3B2K0w4KuwsM= 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.18 0544/1095] mtd: rawnand: meson: Fix a potential double free issue Date: Mon, 15 Aug 2022 19:59:03 +0200 Message-Id: <20220815180452.050529873@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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