From nobody Fri Sep 25 21:40:58 2026 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) (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 A5DE34F646E; Tue, 8 Sep 2026 09:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.211.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788860200; cv=none; b=PW23R51/sJnvElpIM/I7ylHAy8iBeCSeaoYZGNJh4ybKOjI6T2Ve6qeU0SjWDDdsuG6zF2jK1HrTGa9TmHpmlw4ofgSL5K136LwXkpLcG0wnORwDRdNgwXxRp2tQ6Yq3JoUtHD+Pb31K4jbh6If252xo+b6QfXML7FQ9c4IDWJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788860200; c=relaxed/simple; bh=hju+miMB0DwsEai/Rn4SfGeACJ9vRM7dxqY4Nmuz1HY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o9Yg42nyf0BleR8U37BxQ6Wl8DpfTQIaU1JC3SMGNkLcdTXWxXea7ydv+EavnvBWtu0wsOjp/pWQGJTqse+TccJynjaG73ToA4zRV57pRSH2kd6NsyXgZUY9rtStygzjL67KU6+sFJH9Tt/H2Ii/s8r/FF5VbH0jeFEX2OD6HC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru; spf=pass smtp.mailfrom=swemel.ru; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b=eNMBG6Jv; arc=none smtp.client-ip=95.143.211.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=swemel.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="eNMBG6Jv" From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1788860187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ryfKdL4DfllftOGcpI0AMPFnyaoULNI7HFXLFjKK+wQ=; b=eNMBG6Jvm44p5xnQvyl7oqfYvOVgpe569zC+pbT3kwla+IkMOl3F7d6WQzL7VUAVQHSyM8 eY+Vxdx9Nof/HPPRbFA+n58OJxLwgUufBVP7Qwz9t8qymF37HSJEzxWqk+2WnBw9h5iF1q S8XmvY2E532kDgVorz81nkmqDtfL0Ks= To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Sasha Levin , Artem Shimko , Stepan Ionichev , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2 5.10] serial: 8250_dw: Use dev_err_probe() Date: Tue, 8 Sep 2026 12:36:21 +0300 Message-ID: <20260908093626.15492-2-arefev@swemel.ru> In-Reply-To: <20260908093626.15492-1-arefev@swemel.ru> References: <20260908093626.15492-1-arefev@swemel.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko commit 57f83e5dd6a33c4696699954784f8fee789b1d0c upstream. Simplify the error path in ->probe() a bit by using dev_err_probe(). Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220509172129.37770-2-andriy.shevchenko@li= nux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Denis Arefev --- drivers/tty/serial/8250/8250_dw.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index 211dc88ce4e2..629eb24166b5 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -451,18 +451,17 @@ static void dw8250_reset_control_assert(void *data) static int dw8250_probe(struct platform_device *pdev) { struct uart_8250_port uart =3D {}, *up =3D &uart; - struct resource *regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); struct uart_port *p =3D &up->port; struct device *dev =3D &pdev->dev; struct dw8250_data *data; + struct resource *regs; int irq; int err; u32 val; =20 - if (!regs) { - dev_err(dev, "no registers defined\n"); - return -EINVAL; - } + regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!regs) + return dev_err_probe(dev, -EINVAL, "no registers defined\n"); =20 irq =3D platform_get_irq(pdev, 0); if (irq < 0) @@ -547,7 +546,7 @@ static int dw8250_probe(struct platform_device *pdev) =20 err =3D clk_prepare_enable(data->clk); if (err) - dev_warn(dev, "could not enable optional baudclk: %d\n", err); + return dev_err_probe(dev, err, "could not enable optional baudclk\n"); =20 err =3D devm_add_action_or_reset(dev, dw8250_clk_disable_unprepare, data-= >clk); if (err) @@ -557,20 +556,16 @@ static int dw8250_probe(struct platform_device *pdev) p->uartclk =3D clk_get_rate(data->clk); =20 /* If no clock rate is defined, fail. */ - if (!p->uartclk) { - dev_err(dev, "clock rate not defined\n"); - return -EINVAL; - } + if (!p->uartclk) + return dev_err_probe(dev, -EINVAL, "clock rate not defined\n"); =20 data->pclk =3D devm_clk_get_optional(dev, "apb_pclk"); if (IS_ERR(data->pclk)) return PTR_ERR(data->pclk); =20 err =3D clk_prepare_enable(data->pclk); - if (err) { - dev_err(dev, "could not enable apb_pclk\n"); - return err; - } + if (err) + return dev_err_probe(dev, err, "could not enable apb_pclk\n"); =20 err =3D devm_add_action_or_reset(dev, dw8250_clk_disable_unprepare, data-= >pclk); if (err) @@ -616,9 +611,8 @@ static int dw8250_probe(struct platform_device *pdev) if (data->clk) { err =3D clk_notifier_register(data->clk, &data->clk_notifier); if (err) - dev_warn(p->dev, "Failed to set the clock notifier\n"); - else - queue_work(system_unbound_wq, &data->clk_work); + return dev_err_probe(dev, err, "Failed to set the clock notifier\n"); + queue_work(system_unbound_wq, &data->clk_work); } =20 platform_set_drvdata(pdev, data); --=20 2.43.0 From nobody Fri Sep 25 21:40:58 2026 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) (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 819E039D3DA; Tue, 8 Sep 2026 09:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.211.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788860200; cv=none; b=n4nZWK2Hd/wEv/PIZU8xnXNpbsLUZhQW2vaxWditJBc84tQjuiX1PKfhj0U2bfi/UWHPs43XBoXM9RGqK2YODDVDSOXskHXmAYqQAMsRemEiteqJXP4v7Hvd3jz/0kg7YyRVM2HaJT/01BsKftKOhxx+AquAHec26giu3zLv/7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788860200; c=relaxed/simple; bh=W+2anHyHRU14MUZi9nWeel6a7Klgj+ZAIu1ugPIti40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L53V2o2ZS5Fcdkv+WHCtSbHtQyvMg2VXB1WR3rVrnMvtCl3vBBNtj7f/VDt7Zl9vc4MCyZLGtTuVSGBpNVPRDjjHVmbh84v5jus+s/zGl6mjAh+wJJ0AhOpDQD8omQ62VakNRKtUiPnx83nlVrk/ONHLBIMApkU3i2BXpDOMK04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru; spf=pass smtp.mailfrom=swemel.ru; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b=akQ3zzA6; arc=none smtp.client-ip=95.143.211.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=swemel.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="akQ3zzA6" From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1788860188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kpq/dM2FXhmvz9NaLq2Y/fYUID515C4TuKswVMl89ZE=; b=akQ3zzA6kD3+HP+5X1KO9yuE5SqmCkAyFixh0Y1O+cR364HtHxkmSMFjtzrpkBBVmEH3DJ SZWY73qeSesmuQA56ZtslHc234GiiDLZbYtgftg9zWebNEf2qdM/hldYSPTqxK/kXPr9S1 +a/yYGOdbjeV/fptF/YlhatHlk1r92U= To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Sasha Levin , Artem Shimko , Stepan Ionichev , Serge Semin , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2 5.10] serial: 8250_dw: unregister 8250 port if clk_notifier_register() fails Date: Tue, 8 Sep 2026 12:36:22 +0300 Message-ID: <20260908093626.15492-3-arefev@swemel.ru> In-Reply-To: <20260908093626.15492-1-arefev@swemel.ru> References: <20260908093626.15492-1-arefev@swemel.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 conditi= on") 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 [Denis Arefev: adapted for 5.10: - system_dfl_wq is not available here, use system_unbound_wq instead] Signed-off-by: Denis Arefev --- Backport fix for CVE-2026-53384 Link: https://nvd.nist.gov/vuln/detail/CVE-2026-53384 --- drivers/tty/serial/8250/8250_dw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index 629eb24166b5..0afcfe4ff56a 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -610,8 +610,10 @@ static int dw8250_probe(struct platform_device *pdev) */ if (data->clk) { err =3D 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); } =20 --=20 2.43.0