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 5EDD629B78B; Sat, 30 May 2026 18:04:44 +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=1780164285; cv=none; b=oyybr1IiVGSVOJAQkitplTSP4S1YbKbSkKK85XF3Eez2589icc+cOfILAXB0rtY00SsriSxIH0Sq79mCe4tlCS5DxQZQ2J7Oj6Y5E4jx9QwQXRnX3pZYdoBmasmW7N1QFGUKe0Jp2PS1hPQD0wkmTYsF2eYnaJ2NyVcgVB2CZHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164285; c=relaxed/simple; bh=1JN953qYa+bf2R5tHuWr/gtDQoKOjXUsUbxtB6IRJ64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MxoQdmKU/P7ZBCd3U/Fgnzssf2ioTKnvrM5HbJpn9UqevNcQ7hXkKeEkjzn5g0c9RfyGwROd1J0yP1KskTekazd1AibnSCiytlUVPX7uqxluGL1HPbKTe2se12BBYzqm0b6EEhWZP8U5K913RoS2UTkmzN4v1sH1hbVKAty7HZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HF3JXWsE; 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="HF3JXWsE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A36251F00893; Sat, 30 May 2026 18:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164284; bh=gIE5pH/aqtlwIApFQYJyoIFOtVOZlSM8MOom2kS1zWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HF3JXWsEOxRK/FRUoL+jnaLAhXvVC1jM6MMT91yRuYdQab6BU++eiDNs+ODCn12Ad oCTUIx1Vj17yXUtxQClw/z66YGF6vveENbMFFji7usjc4wxJ1JVIc8KFbwH/3Kvfzu mkS+WJrw+lTnvS35fgTcYk8Sq1N/8Spyy5qyrS0I= 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 5.15 509/776] mtd: parsers: ofpart: call of_node_put() only in ofpart_fail path Date: Sat, 30 May 2026 18:03:43 +0200 Message-ID: <20260530160253.422983960@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cosmin Tanislav [ Upstream commit 0c87dea1aab86116211cb37387c404c9e9231c39 ] ofpart_none can only be reached after the for_each_child_of_node() loop finishes. for_each_child_of_node() correctly calls of_node_put() for all device nodes it iterates over as long as we don't break or jump out of the loop. Calling of_node_put() inside the ofpart_none path will wrongly decrement the ref count of the last node in the for_each_child_of_node() loop. Move the call to of_node_put() under the ofpart_fail label to fix this. Fixes: ebd5a74db74e ("mtd: ofpart: Check availability of reg property instead of name property") 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 20af45a7270d5..7ac5ba6edd63d 100644 --- a/drivers/mtd/parsers/ofpart_core.c +++ b/drivers/mtd/parsers/ofpart_core.c @@ -172,11 +172,11 @@ static int parse_fixed_partitions(struct mtd_info *master, ofpart_fail: pr_err("%s: error parsing ofpart partition %pOF (%pOF)\n", master->name, pp, mtd_node); + of_node_put(pp); ret = -EINVAL; ofpart_none: if (dedicated) of_node_put(ofpart_node); - of_node_put(pp); kfree(parts); return ret; } -- 2.53.0