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 5A676436378; Wed, 20 May 2026 18:39:06 +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=1779302347; cv=none; b=U2PCTQHxvvUDQwAZrUOYsgqViOS4/5ry8cjWZZ2IEpdEgyk8RtKepUohv9vQ4MBebIc7bdiqwlc5RpjkHSKTZkjS1hV1CDE8YvBL2XBukHpb4jCsua02UCpiRWF9Je8Q8CkWS72MxsOXPu2WoC2OrvM4hEjQUqB0u8tTI7NL2q8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779302347; c=relaxed/simple; bh=6oCnVgV58vMqJKnKh9xStUe8PWgTRBwWMsxMHwyJXms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdsdKh6parvnAHKZpzhVum6tgjS4JAdDfqWdztrCdmgzOuefSHfVKHluUR0/+7sMyaxSw+3RKp93Gs5GOtCDLe2KgAbmrkXiAWofYRjU9EBAAa8ZF0AOt4XhRIFwqrUZi2mvoA2LinPKNShxP9LtGQxp9PM3W9YJ1xMbGY8TEnA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ctP9+ir/; 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="ctP9+ir/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC541F02831; Wed, 20 May 2026 18:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779302345; bh=zFIMV5ZTlAqdCuz81AfjyKxzQph9WsIdATJE5/IrUOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ctP9+ir/COqScbPqn4k6cXyDDSGp/E+r3S4XNx22cDwhjNzoRXXwKcXn6nInMqUfK BZNwwUwVGQp/f7faxifgUuFXArI9lVEA+nAJMtUvevvNYYpe7K/c1PksWEvxYRdm5s fF4jRA4cNdESfELigKgfWhn/nfAGX3MFTacXcyak= 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.6 232/508] mtd: parsers: ofpart: call of_node_get() for dedicated subpartitions Date: Wed, 20 May 2026 18:20:55 +0200 Message-ID: <20260520162103.677392913@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162058.573354582@linuxfoundation.org> References: <20260520162058.573354582@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 110994b1e02f5..c18fa1b3e3276 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