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 489EF3A7839; Thu, 2 Jul 2026 16:44:21 +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=1783010662; cv=none; b=Pgc4QyuWq++3zIJ7Xj5bD6mhNpHtu0m9oaslwbcJYlUFoJPfDpagX6REf7PorFdd1wBkbxGZAQimhDRM1dca4Xf+PyhSs+BDJ4kwvp6ATsSOsjAjcv87mRqgrXOZf8xFwo4ntIs3FVzDonzQK8t6iAp2oAuN6E1vwyR4yh23Q5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010662; c=relaxed/simple; bh=c4BOpQUXfVN1cpBO+lfff+VysCnAWmGxMDdAWHdyN6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gOfU9IftdfMpjJDkA10wqBAqdAfE7ZN2VWPltVzP1/ZXqH4PICyi4f1E1BTsCTc7HyN80lA4mWv3a8Zy6/6LGekwBOZU/P5mQSLeU6mkVvJ4qKfxXcAJdgyUq2Gc0alXKFh5iyki1A4P2b3nIVYrn3CnVRbe2I3CAB1jn8KMMBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bDuPHqcV; 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="bDuPHqcV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF0E21F00A3D; Thu, 2 Jul 2026 16:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010661; bh=5aqnngcBe45/xfK5AwdK38883pYupLXqKffaQmFO04o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bDuPHqcVovOLSpHRh8cy4LTtp/uo/xAb5DfsKr+TZihkSWWoNSnegspav/x+pa6yX aQeB5otDDPr57AERQV6YJwD3RbCV+mrRHs7CqiPsoWV+VTCBRLG2Ud35Wlpbvt1361 WSTyhiAYIz8hCDoHv7FTkkq6czDgnoVoLpdS9YhY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Andy Shevchenko , Sasha Levin Subject: [PATCH 6.12 193/204] serial: 8250_dw: unregister 8250 port if clk_notifier_register() fails Date: Thu, 2 Jul 2026 18:20:50 +0200 Message-ID: <20260702155122.704295311@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@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: Stepan Ionichev [ Upstream commit 10fc708b4de7f86002d2d735a2dbf3b5b7f65692 ] 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 Signed-off-by: Sasha Levin 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 @@ -655,8 +655,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_unbound_wq, &data->clk_work); }