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 E0FF12F8EAE; Sat, 12 Sep 2026 14:16:58 +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=1789222620; cv=none; b=SF1GjzBcoSoyUnJ0E+rP8ZGu8UpSJAyQrf1jE3As/qoNgHSX/IMEeTiXdphsEakI1w/n411HSE6168DMT7puyp93KIBqFqlBT2bxpzd06ZtHycIVV1BqPqBf0JHySUlIne+210fcyB3ONoEMqmOt19bE22n/4zrIjvgX0pQHUZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789222620; c=relaxed/simple; bh=TxbfbLkmc5Qjb8C8xKSedv+ZmUtIUydBGjZrord8DsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oc2CUjFQJl4Pyx9FVaQJ3+Myg5KSz5e0aGm7GS4o9x6YKBvqRFrlX7hr0qnuFUKrIIa3YDO5DMyFDKunUSJQOpfOeO6O4V4H2/i32rB+HIwTHAkmjn4N70A4BLJc5szkuGankAydlwnaMa+a7dK2M9NZbV2g/M7rYCZnBMem2Tw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ElpgqvyO; 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="ElpgqvyO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A2C91F000FF; Sat, 12 Sep 2026 14:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789222618; bh=WbXORBBkXby8YclNesSopXrozE/CT/Jps8j2TbYm4fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ElpgqvyOYkxz2O8Kfy0UYDlMDufgXjQpP829Jfy+RdJU8L7x98hSNf8Q1659olENW 3O9LLv3+qR/8+qinmBQgZZT6B7LGqEElSFBGPplpGslRFMNs308bqQmAYM6mPZbBww qcEjipUUCSnl6pCaUYPSaiTxxuLNjA9907yBqmsA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Weigang He , Frank Li , Sasha Levin Subject: [PATCH 6.6 0586/1424] ARM: imx: fix device_node refcount leaks in imx7_src_init() Date: Sat, 12 Sep 2026 08:50:18 +0200 Message-ID: <20260912065620.415514235@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@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: Weigang He [ Upstream commit 3de939b2ac843d56d88e2ab1e1b1f667cba9e1d4 ] imx7_src_init() obtains two device_node references via of_find_compatible_node() - one for "fsl,imx7d-src" and one for "fsl,imx7d-gpc" - reusing the same np variable, but never calls of_node_put() on either. On every i.MX7D boot up to two device_node refcounts are leaked: - The "fsl,imx7d-src" node is leaked both when of_iomap() fails (the early return after the mapping) and when it succeeds, because np is then overwritten by the second of_find_compatible_node() call without releasing the prior reference. - The "fsl,imx7d-gpc" node is leaked on every path leaving the function after it is acquired. Release each reference immediately after of_iomap() consumes the node. of_iomap() maps the node's registers but does not retain a reference to the device_node, so it is safe to put the node once mapped; this also drops the first reference before np is reused for the second lookup. Found by static analysis tool CodeQL. Fixes: e34645f45805 ("ARM: imx: add smp support for imx7d") Signed-off-by: Weigang He Signed-off-by: Frank Li Signed-off-by: Sasha Levin --- arch/arm/mach-imx/src.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-imx/src.c b/arch/arm/mach-imx/src.c index f28bfb653a88f..c3c80b4c3d53b 100644 --- a/arch/arm/mach-imx/src.c +++ b/arch/arm/mach-imx/src.c @@ -196,6 +196,7 @@ void __init imx7_src_init(void) return; src_base = of_iomap(np, 0); + of_node_put(np); if (!src_base) return; @@ -204,6 +205,7 @@ void __init imx7_src_init(void) return; gpc_base = of_iomap(np, 0); + of_node_put(np); if (!gpc_base) return; } -- 2.53.0