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 460DB47886D; Sat, 12 Sep 2026 12:05:05 +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=1789214706; cv=none; b=tPAhkLaTdaGijQftKK+/WRlxvNZT33ROtm7/4M0Q0p140/yIaGibmlsWmCSSGBCafedOUJWrh1Uo0TwFRP3jkbGrUWChgcOL9Tp3y/Y4NcCQ4Moq2LldXWmd9r0TKCgajnyLGSP9Nwi2Wfv3ncm9QTAMDU7QycGe7VPo1rICs1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789214706; c=relaxed/simple; bh=t6ek7LN5W/9qXgNhg0KGXUMlbn4j81g18Hz7qzDxlv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qKcppN6U2Xg4xgtu1GqVBJyMw9kKnHgPd80gv59qtopOCjOxghKXWULiZ1h2sOobI/pR6ww9U5h3KTv/tqaP7P45vQZE/0UGIqqTvkjNbmMNfi9A77C4sbKkV9YWZvDOO80NUvbgHcJAmenqVRVsRwZbUCMCL5J+UO1GxMSxcWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Kxd5Fe/y; 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="Kxd5Fe/y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61D051F000FF; Sat, 12 Sep 2026 12:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789214705; bh=lO1v74ocHu4JaM+kJJet6nbirctKotDrrKarB+OZCKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Kxd5Fe/ykJ7YRL7tgysfvJ8fyR40XUcYrFhqakGEquj4sBwuZQMxUQsC432FLnSas +ESjY6Qw38UwWIXOlYU9mGHiXtlk3eVVL5lCg0UbVbmh3Zi2H74P3bLYxeVcgMm9ed EBalepCMlgeICPkPgvvHFG3UZrCtGW5bstOyivKE= 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.12 0339/1376] ARM: imx: fix device_node refcount leaks in imx7_src_init() Date: Sat, 12 Sep 2026 08:46:05 +0200 Message-ID: <20260912065615.107567462@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@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.12-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