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 13A982EA480; Sat, 12 Sep 2026 07:30:17 +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=1789198219; cv=none; b=sktUuRH7r+DrmEY7Q7XO+IkzLAKwze+mOm2V80jrQ4KphDGU3ykL55vgw2RjXWapK+k2Uc1otFHgMtEmuXwvM8XVSWCvgu5u4sg5+QmUETZH2/x3NihwY3YFiabutfRVRx76eOTiiyDzPISMnrR8K5v71WQ5Ks03R9dSrRZN6q8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789198219; c=relaxed/simple; bh=VWJAutqpC45I7ftST93XBUliUuFttHIEpJaXyZFCNlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2OfBzv+YQZIQdaLGYTWqHQdcGotkeUA4RmjTAnEQLZ85AD6cY/ScxdQHz7FYMUmpPBXanOfmaX+SJHiZqj8ET1ZA0yf09/ZdWxxUn9X6Lj/R/rHxCHjoNXhgupEkejjSC5ULnTK5XHkwhmpg16Y+oIcx/eO4/gDV8cm7YzkrBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AbThFH87; 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="AbThFH87" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 731CC1F000FF; Sat, 12 Sep 2026 07:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789198217; bh=CS2eEz1uhwvBS5N+WTIdmDjADOqFKpo8TYtqnR+Ypbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AbThFH87SRwZNScgmDhKKtR0Rq8kkeszHMKMCei6dBPZ/MU38AF/oyMNBBqfWxeOo 20Pw7rwY+Wiu/DydxBx7xj0srpUrv+bqEtjaEXpF2DAoIARp9Gc/M31bMTcNIUbnC0 Lvhz3X2EWoHpTE0rhesfOIiyhNEfQ2SV7JtF9C+I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuho Choi , Sasha Levin Subject: [PATCH 7.2 0318/1815] serial: ma35d1: Fix OF node reference leaks in console init Date: Sat, 12 Sep 2026 08:34:28 +0200 Message-ID: <20260912065656.403985004@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuho Choi [ Upstream commit 8dfea56f350b3dc826f35711802ad6ae8fae0748 ] ma35d1serial_console_init_port() stores matching UART device nodes in ma35d1serial_uart_nodes[] with an extra of_node_get() so that console setup can later read the "reg" property. However, the stored references are never released after console setup has finished using them. Drop the stored node reference after ma35d1serial_console_setup() reads the "reg" property, and clear the array slot to avoid leaving a stale pointer behind. Also release the iterator reference before breaking out of for_each_matching_node(), since the normal iterator advance will not run in that path. Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support") Signed-off-by: Yuho Choi Link: https://patch.msgid.link/20260630214043.1887351-1-dbgh9129@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/ma35d1_serial.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/ma35d1_serial.c b/drivers/tty/serial/ma35d1_serial.c index 285b0fe41a86a..920fe7ff5083b 100644 --- a/drivers/tty/serial/ma35d1_serial.c +++ b/drivers/tty/serial/ma35d1_serial.c @@ -608,8 +608,14 @@ static int __init ma35d1serial_console_setup(struct console *co, char *options) if (!np || !p) return -ENODEV; - if (of_property_read_u32_array(np, "reg", val32, ARRAY_SIZE(val32)) != 0) + if (of_property_read_u32_array(np, "reg", val32, ARRAY_SIZE(val32)) != 0) { + of_node_put(np); + ma35d1serial_uart_nodes[co->index] = NULL; return -EINVAL; + } + + of_node_put(np); + ma35d1serial_uart_nodes[co->index] = NULL; p->port.iobase = val32[1]; p->port.membase = ioremap(p->port.iobase, MA35_UART_REG_SIZE); @@ -648,8 +654,10 @@ static void ma35d1serial_console_init_port(void) of_node_get(np); ma35d1serial_uart_nodes[i] = np; i++; - if (i == MA35_UART_NR) + if (i == MA35_UART_NR) { + of_node_put(np); break; + } } } } -- 2.53.0