From nobody Tue Apr 7 21:45:14 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22F6F3B0ACA for ; Wed, 11 Mar 2026 15:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773243668; cv=none; b=BsvNzrdw+yKYse6JT4zXk1hOpfOeXgUdlnL3Q3KNWAj75dtJnoDnK79mlSYFouzF+PLQZ1/DBb1YA4VsOQFMn7lZavbzgxWkCZQuYuta4CQ84KAXUkrPGL0Io4umwPQSd3v3jHO9aoJcYo2HuoUlV1M4vvCMvVusnjQRvGJ3OdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773243668; c=relaxed/simple; bh=PDlrPcI8evaVnQaIB06v5rg3S4xUymoyhst24988xcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fXGieZYzhST+Dhf7TJsXdQ+J6v+q/EMVaw8wUmdFAEVkIr38YBUI68nZ3/oiYPEJIQiAl1CDHiknQ3sfKVGEIH22fUTPxX8D5Zdr9BSb8g4b9GbNokFZHIotobPaKllAJDF1VEvpU7XpShhDdxqDxR6KRrYBMJOPiblUi4R3ARc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: u/B08nQjRbmhAA6i5QQrEw== X-CSE-MsgGUID: LNCRiv/SRhiWB2JHTIsMJw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 12 Mar 2026 00:41:00 +0900 Received: from demon-pc.localdomain (unknown [10.226.92.22]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D7DA2400ADB5; Thu, 12 Mar 2026 00:40:55 +0900 (JST) From: Cosmin Tanislav To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Cosmin Tanislav , Kees Cook , Weigang He , Daniel Palmer , Benjamin Krill , David Woodhouse Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mtd: parsers: ofpart: call of_node_get() for dedicated subpartitions Date: Wed, 11 Mar 2026 17:39:57 +0200 Message-ID: <20260311153957.1984446-3-cosmin-gabriel.tanislav.xa@renesas.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260311153957.1984446-1-cosmin-gabriel.tanislav.xa@renesas.com> References: <20260311153957.1984446-1-cosmin-gabriel.tanislav.xa@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 pa= rse_fixed_partitions()") Signed-off-by: Cosmin Tanislav Tested-by: Tommaso Merciai --- 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 181ae9616b2e..262c4221d23f 100644 --- a/drivers/mtd/parsers/ofpart_core.c +++ b/drivers/mtd/parsers/ofpart_core.c @@ -75,7 +75,7 @@ static int parse_fixed_partitions(struct mtd_info *master, dedicated =3D false; } } else { /* Partition */ - ofpart_node =3D mtd_node; + ofpart_node =3D of_node_get(mtd_node); } =20 of_id =3D of_match_node(parse_ofpart_match_table, ofpart_node); --=20 2.53.0