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 1680F1E633C; Thu, 25 Jun 2026 13:11:01 +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=1782393062; cv=none; b=MCGa48WWiUR2W5FsUGkrI3HX1BV6m7we+8wVc/nX7g3GIU6y8pLormtk8VRzWm83Q5x55mS6j5t84uM0P/RIK9MTW0UdIaqYqoChRlADdt1Mp4FKUoa7GSLquAkPdR7B+G5BfSGK+6F/zErfg/p1TuXp0SX2X46QfBHRUnq0vy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782393062; c=relaxed/simple; bh=JxP+HrLc20IkYWJcZLt8j/4+PNLRM46CuKxjkXi6FOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HhPaxsDIZP08tNfrh7cfFpFX+sV/l+mpReXBEYpp/LHv7KY3OOuL1G0nmxvPw7GPF8+Pki56F8dPZ7D6MAabAiLBLI2iYQndEETPYgpi2RLrPSbQ/UliNUlMq2WUJTjtEw/vi8tR6G+oY5BlbGNHPCXQJKRVZvtRTpUuaSCFf4U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MauiCgrQ; 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="MauiCgrQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 575201F000E9; Thu, 25 Jun 2026 13:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782393061; bh=Ou544/6FvvoIfxeGRIqAxkPhH8fSiSoDPAeUIg0jlpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MauiCgrQoI+xQl1tgelX4qWqw7PlipB0IR61Cj971Ga536GlCxtvuvYwZ70e1z5bo MmVaxJBq6yo+X6tsZJ9t0a1NtN6dtXEJSYDaQ5SWK2G1Kz9rQu+tEn4gzbytBeO/yG 5s3P022W6W66aILtImYIE4k/RsCQl52fK+XM/Pik= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Andy Shevchenko Subject: [PATCH 7.0 45/49] serial: 8250_dw: unregister 8250 port if clk_notifier_register() fails Date: Thu, 25 Jun 2026 14:03:57 +0100 Message-ID: <20260625125643.851493371@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260625125637.527552689@linuxfoundation.org> References: <20260625125637.527552689@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.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stepan Ionichev commit 10fc708b4de7f86002d2d735a2dbf3b5b7f65692 upstream. dw8250_probe() registers the 8250 port via serial8250_register_8250_port() and then, if the device has a clock, registers a clock notifier. If clk_notifier_register() fails, probe returns the error but leaves the 8250 port registered. The matching serial8250_unregister_port() lives in dw8250_remove(), which is not called when probe fails, so the port slot stays occupied until the device is rebound or the system is rebooted. The devm-allocated driver data is freed while the port still references it (via the saved private_data and serial_in/serial_out callbacks), so any access to that port slot before a rebind is a use-after-free hazard. Unregister the port on the clk_notifier_register() error path. Fixes: cc816969d7b5 ("serial: 8250_dw: Fix common clocks usage race condition") Cc: stable@vger.kernel.org Signed-off-by: Stepan Ionichev Reviewed-by: Andy Shevchenko Link: https://patch.msgid.link/20260514143746.23671-2-sozdayvek@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -850,8 +850,10 @@ static int dw8250_probe(struct platform_ */ if (data->clk) { err = clk_notifier_register(data->clk, &data->clk_notifier); - if (err) + if (err) { + serial8250_unregister_port(data->data.line); return dev_err_probe(dev, err, "Failed to set the clock notifier\n"); + } queue_work(system_dfl_wq, &data->clk_work); }