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 A1E7433FE15; Sat, 30 May 2026 17:16:45 +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=1780161406; cv=none; b=VYoIc0VerCzFpwA7QaGfY00ShjAqb57TjeGsvWyybFlSh/4/z774C2IK2eUr40mnM33zOlF7P562b2n7v+ow0vhZxJsLmV51PIln358y7sbwHxB8b4yKkt9yOrPQekCtPpnxvTVr82+JQJBNW6owUDQNeUhdP/GHVzwtVylCRM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161406; c=relaxed/simple; bh=eswXLRtZC77JL6HxBjFx/adqEe3dtZPBeH2Asnm+hzc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=toTwsG+HFcRHlwkiMMVn6ZoSfx0Hylh1aNrDHRkaiJ37zTuJDovVzCks+U32JGh9nRldCtVEOVjPxAeC7pc2BIbrJZ72Lq9FD7bUbSTDTtXzT1bxZV9KLY2st5oHk3uiLWVIeC4W1N5yo16xU26Avt8hjq011Ls8yLrkCeBwEqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IHcUjIVv; 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="IHcUjIVv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7CD81F00893; Sat, 30 May 2026 17:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780161405; bh=z5usu+MCCsb7oupndZlH1DAaEE9T4JNjekxKYlds3tY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IHcUjIVvOXhfzRAYWQstR6UF8QmueRyPZG/mMJH7QHpghs6gen7fvVXku8VbO7IvG NnxiEMYvAvmm0yvfxbJKcUtE/IL4zhM4DR9vi6vq0eUumY0Huye7MepYzQlclMpFRn K+m7hKSZ4OU2TENF56ECtQ3eN44knWIgEYwDkgts= 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.1 615/969] mtd: parsers: ofpart: call of_node_get() for dedicated subpartitions Date: Sat, 30 May 2026 18:02:19 +0200 Message-ID: <20260530160317.417071010@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@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.1-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