From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2285F349CCF for ; Wed, 10 Jun 2026 05:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781068019; cv=none; b=TDX0sinqdyLO3Lkj62EHrd/+SbLEOQwiKrvArQzMhQ4xZudTLmbbIsT32TjWanxHVUJO5lFN3ITz7PLCIO3E9A7wdrPobpUKxUlgeH+asRhBy399bWNWTnUJg6EXxCu1M38/L3tVMEfFxP1+ZdRwJegw95DB1MRWbx/NguguyfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781068019; c=relaxed/simple; bh=ObATbY9LnO8WiYOe/oY/3Z7+PZzAkwe4OL79QWUiQAs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MX2lARzgoSbB8zBhcF9kRYLDUNWANf4jW77gFeFKiondIPZI434H2s57icjDtZPlOpvcueAErycEVJT1os4xeWl5Mo8i/Z5bGfMzEmvn/FM4Yl7koKQLnuyMQzbdHnRtamgmBhj9VllQTbwSqNe3669m0mt7uoX1wLGDiKl5h24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WYGYf3Fg; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WYGYf3Fg" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2c0c1e0b0faso43560185ad.0 for ; Tue, 09 Jun 2026 22:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781068017; x=1781672817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fmpW0QtKL7WDZjfsG4xvFm11JV+f+bzZkKOrbkR0yY0=; b=WYGYf3FgW01D+vWkevnMh/KU8BS3zg7hfZTduzmkYUiNWS2LBgc+GuFYX7zhQmpmZT CmSUTIxzZEB5AsAps5QS0PfD1kw2kwudQGT8czNIlT+bkcm9NGGt2PkDjH//Vye/Mo23 VQiDD7sjoFjrj6bjYFGaGa9Q13P5JWwcGPxbrp1ogTW9gZWto3Sfu20dQjiwn62EluM0 tiA+02QlSNiE935YgOu/tof7yVB62rUSkeVw8JZugIYjbWJa9KDWkRGkVY9xfDYKbVd0 pbxmO6X6K9FQsFVq9uJaZSHCT1XEu0PsI0pJMHEPVAqzbE1DVD53hrasx3GhGjPcqMvn GwTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781068017; x=1781672817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fmpW0QtKL7WDZjfsG4xvFm11JV+f+bzZkKOrbkR0yY0=; b=PQFGWQmRt20S2BvT1i8dwC1dkFBH4mqE7wb2s8NN2XQPHwXWLvDiz49T9/ey2TLwBa tNYMYm+9EFbzC7IbgRxxX2+gp25Si0SOcaeGb92SZqKE8CHkD/pb2S4MgUYSwhrgiikU SVKPU2jRe1KLm1Lr2sAcqm4ohfysySuRHpKJWKPzPzVi+UCr9JGmu6hfvoq8RXT5MFwc R9KcCR5fil/TnSAiygHsBhmgMyXN+fHMrckMsJBW3qxiPk2Hhp92mU9jGijg9F7/37qm j1uD+Pq19pjGUe6YkndHON5JvOkUkXbQyLkLAFw4UszTJGYjNrEwHo25A2rK/WkpdPQm sSTg== X-Forwarded-Encrypted: i=1; AFNElJ/rycj209FWSs3MgsARUBB1VM6pBmlQ0atSmpH/jmgpLOylsXutUhVcKTYXASF8R5F67vmcKG6K1defFgc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1O/JGPKY2ldS2/UcoxLB7e0fixreufIcq6aztnlosUibPAu8Z tocdzr77AUOfQ3pO81//1aFr4ExcH216uPVdtI6x2FeoUX329xOt8cr4 X-Gm-Gg: Acq92OHkG6rEXTpkJKvbVePO7OKQHssv07G/wQSmi+1+3zoenBqmrSgvengqHEeHcik ebNqpBxN5cCbXlLXZiE0PnM+xL60QHgDyohhWy0ZIsK08VxBYRz0k9lNYomxun1jLPSM6wTK08l 16rcA1ZXN49ewMiNlBxfHfdyAUdvSjKz10ktNBEOREfK8UJtO7U5jXAcWV9STTiP+WTavzt0ijM hgGtDMHPOtuRAdK3ZCm2IhupH1INLVkihuG8rn4c8R8ZyWEa3PHKZdsZ8JKRq/1YvRwmO7Y9cpq f1lE3sLQjEr1ftv9ySjROgNAaPXYJm+m98w5CZOa98uqJV87OGRic5L4qv1xt+Vmg9TtCDHSErU Ydujje9o8jQb0/1XWSwmT8yukm4FH528pN3yB+he/+wn282TYuCV8pGG68OE/2kTDKJ6gm1htBw 7i86flGHzlMC8soWYt5ARR2gupHagxztyWpaNrqG9cyNS0eRV2mJoMK0u7XYLbmvB7AzYRQ/+JY bRnpK5ut8vbRyiPNtC+EvS3pVra3lyyx0sMDkRxEMeMBQGSoevLYg== X-Received: by 2002:a17:903:90b:b0:2c0:af09:f3d9 with SMTP id d9443c01a7336-2c1e8350affmr283521355ad.36.1781068012570; Tue, 09 Jun 2026 22:06:52 -0700 (PDT) Received: from localhost.localdomain (n49-176-80-106.mas22.nsw.optusnet.com.au. [49.176.80.106]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f6e2adsm245342055ad.5.2026.06.09.22.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 22:06:52 -0700 (PDT) From: Weigang He To: Shawn Guo Cc: Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Weigang He Subject: [PATCH 2/2] ARM: imx: fix device_node refcount leaks in imx7_src_init() Date: Wed, 10 Jun 2026 15:06:25 +1000 Message-ID: <20260610050625.2229221-3-geoffreyhe2@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260610050625.2229221-1-geoffreyhe2@gmail.com> References: <20260610050625.2229221-1-geoffreyhe2@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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.43.0