From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 531A13D5647; Wed, 20 May 2026 18:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300878; cv=none; b=nUUEym9PsXzUuop6aGSqqYS0uymrTqV6ixKU+ivZjn4ya8TLlqYKuToTTdPssa8BzLUAV5r3qB/Lm8KOfHpsMRZtyj2Xuv4mGsRFeUqULK+TJihTaJklrdvA9fpa/zaD9cw7uH4osz4q+AxEaMbHgMMQEbfp1LOUsNNFmzFYC9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300878; c=relaxed/simple; bh=82KPRt1VrCoE1RvONCkpEUqLtCKkQsDA258e1EmaVSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SrvsjdDmQFAFIYnTa1fubuu8iiM81BB5w6SapPq+8IygU30QhL0zmKFE734i0Z/utQ9V5ADR1j/N5jl3M6Msv0M93YLGSluzlgJdVMpJqhCSrkTYdsNaCiVrKyg8V5TxWRkw1OiaBuzjYHOnZd6w9jHCFyigso/ROF/iPIYq1f8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=haMxOAlP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="haMxOAlP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A95EF1F000E9; Wed, 20 May 2026 18:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300877; bh=6t1CbfLC8OcadGBfYct7T70oTXRp+QQ5M5+HKCXFZKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=haMxOAlPbGZe6kxCq2JzNPRw0UL3NMTVh99ntvtL2mezfB9JoJdmL0CQP7TGzsyjz DtkT47HD/VJ9FWOOXWDodqfaHwLX/J6pVES2Umbr/EDQOwFwgMi+KeTXzuxcOy887f dsUVgaYb26zvlRKX2pyn7WJpxgxg8F3pWFHsnMVE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cosmin Tanislav , Tommaso Merciai , Miquel Raynal , Sasha Levin Subject: [PATCH 6.12 340/666] mtd: parsers: ofpart: call of_node_get() for dedicated subpartitions Date: Wed, 20 May 2026 18:19:11 +0200 Message-ID: <20260520162118.603317288@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cosmin Tanislav [ Upstream commit e882626c1747653f1f01ea9d12e278e613b11d0f ] In order to parse sub-partitions, add_mtd_partitions() calls parse_mtd_partitions() for all previously found partitions. Each partition will end up being passed to parse_fixed_partitions(), and its of_node will be treated as the ofpart_node. Commit 7cce81df7d26 ("mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()") added of_node_put() calls for ofpart_node on all exit paths. In the case where the partition passed to parse_fixed_partitions() has a parent, it is treated as a dedicated partitions node, and of_node_put() is wrongly called for it, even if of_node_get() was not called explicitly. On repeated bind / unbinds of the MTD, the extra of_node_put() ends up decrementing the refcount down to 0, which should never happen, resulting in the following error: OF: ERROR: of_node_release() detected bad of_node_put() on /soc/spi@80007000/flash@0/partitions/partition@0 Call of_node_get() to balance the call to of_node_put() done for dedicated partitions nodes. Fixes: 7cce81df7d26 ("mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()") Signed-off-by: Cosmin Tanislav Tested-by: Tommaso Merciai Signed-off-by: Miquel Raynal Signed-off-by: Sasha Levin --- drivers/mtd/parsers/ofpart_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/parsers/ofpart_core.c b/drivers/mtd/parsers/ofpart_core.c index a5ba78c6723ee..321002a1d0cae 100644 --- a/drivers/mtd/parsers/ofpart_core.c +++ b/drivers/mtd/parsers/ofpart_core.c @@ -71,7 +71,7 @@ static int parse_fixed_partitions(struct mtd_info *master, dedicated = false; } } else { /* Partition */ - ofpart_node = mtd_node; + ofpart_node = of_node_get(mtd_node); } of_id = of_match_node(parse_ofpart_match_table, ofpart_node); -- 2.53.0