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 CF1DF42B738; Wed, 20 May 2026 18:39:03 +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=1779302345; cv=none; b=QSQMucmGwcwJakZ6MbHi/CXfFAeC2zSPfyzDrg8s9/pENoCU4odp0+l/yNL4RdeUi2E20hKqLeAktLkZi+Woj4VNVWmmvZ+dCo/pFza99G//rlKxUfRRwryPueqMMP0/BKDQuNXOhSFqPhVEkA18WLVh6r9CSeU8QIPZucXZ+Jc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779302345; c=relaxed/simple; bh=866RifDa9UBz7hNQky8AnSw674N3LtbtSDXwsSdDmp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cGPbwv/mxt/0wmd/937LUFqgNB7ep6rLeIiTaLBoH2OyQu8DfvKjegXKwlCfpE6fplh1PVrvXf8O1pHt3TVOanZWszDuaCoqMleP638ttRWH9U6JEEUW1ulLxzPYIRbpO+Wwr6+4UzyKR7I+nOHtbF9080uBciCgJ11G528rDC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HLjRg6Dy; 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="HLjRg6Dy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDE1D1F02831; Wed, 20 May 2026 18:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779302343; bh=ZCH9ujvE7Hkjk5As3eOcOaqTdffdqMWWE9hW48R1mYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HLjRg6DyYnAjlvoNBoJq8Jidi6nFGDRem1Oyr0QvHk3x8o6FpYHPc1gFtL4uJQNTp uw31p0UkXT5NjA58cdkdjGz14GXinRIfo2AseTNKnCHUPIt8p/ZYC5WOfXRPjGdLr3 FSZugQqBLEc9ej18nwU9gor+KYKBhgENgEcxE60s= 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 231/508] mtd: parsers: ofpart: call of_node_put() only in ofpart_fail path Date: Wed, 20 May 2026 18:20:54 +0200 Message-ID: <20260520162103.655709648@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: patches@lists.linux.dev 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 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 3cf75b56d5a2e..110994b1e02f5 100644 --- a/drivers/mtd/parsers/ofpart_core.c +++ b/drivers/mtd/parsers/ofpart_core.c @@ -191,11 +191,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