Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3060906rwb; Mon, 15 Aug 2022 17:09:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Q/wCUbLGQgnBPphXCtV93MC5GvNPdnmcc5uliRnuXmW1SL1LLKRnerDwJR9DTn+nL8GID X-Received: by 2002:a17:907:3f24:b0:730:b83d:3a20 with SMTP id hq36-20020a1709073f2400b00730b83d3a20mr12033929ejc.271.1660608587844; Mon, 15 Aug 2022 17:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660608587; cv=none; d=google.com; s=arc-20160816; b=nhDkSq57TepR+y9wb5Vn//C2iQyrRpPxgcDnF7YPuKoFki1XWmj4lv+zg9qTflCddh ZPTTRQJA2p2BfwKlqLu8pZ4htDgU7qv94fSyWhNoKxqDH6CXDiPq0I/Lrel0LmDN6QQp E+QR24995FeRilk5QS7j+lQ3Md0xVld4+/T3vTPraAeUVsVHIEj+FhOiA2ZenYkWkSw3 xV31W5Whrgmln3OnPpybgMrYb+edrr4g7S53a3GJiJmL4znzETOJsh+4CFk2bXrOKtrv VeLwg87V31i//fXRgy9abknwTU4B0FFQhiRY/UOg05NxSDsmm6lHA2xh46CU9Mh/HK2o 1KAg== 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=I3NbLzT2+9zwfOdb9rB/Cx99gPQSgWzfv/5eSjv/3sWDdhFwDfrrTUL3sfJl1C7QxF CR4P6TS2UYsj/aEyQmVxQO7EYB219CuKEmFQuChVYiavmTGAeha1zSxu0B0OJcPPclUv +NuBp0ZBKUAdE4eXJ4BD9Qm9W/fZZxAuj0RySs70nZ8ULLz0+kHGk4pWexH9XJcjO3l4 SNoORrEWb0HJ0LhuEV8voDGeu7Csn8kxF3mdm96uoGFoFFpgxivUkRXo/4jdc/c1xt+l FEdxnOUqmiy9m135AgCbuudKQQIiQ5N1L3+8xsSdUCET1w4/VjlmmrxzK/3nu5ZCDXf3 ycdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LTZL8zlb; 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 sb31-20020a1709076d9f00b00730d106e81asi9964138ejc.255.2022.08.15.17.09.17; Mon, 15 Aug 2022 17:09:47 -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=LTZL8zlb; 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 S1355735AbiHPAG2 (ORCPT + 99 others); Mon, 15 Aug 2022 20:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353878AbiHOX6x (ORCPT ); Mon, 15 Aug 2022 19:58:53 -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 B2D5E79ECA; Mon, 15 Aug 2022 13:20:55 -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 71520B81135; Mon, 15 Aug 2022 20:20:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A80A5C433C1; Mon, 15 Aug 2022 20:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594853; bh=JDV9LBwF5joWK8HGi4wBwjEykNxNVY96ePmNBMJjcug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LTZL8zlbdu/9tZC6fwtHZlvICpl1zLtzUGIzxgl92HgIxkUMTNQCrW/f1VDyBdGu0 9LLvimZMtg3KI2UIYXxuo5NUlLAuvd2oqn2nXhZ7NXrNxsP9/Kc86MEWYj069vcf1d tLXL6JLsZFAnxf4dY//ja+lc8Sq0ej0VzNzKn6SM= 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.19 0578/1157] mtd: rawnand: meson: Fix a potential double free issue Date: Mon, 15 Aug 2022 19:58:54 +0200 Message-Id: <20220815180502.759849232@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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