From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387559; b=ji+twxxJ+HngOMd8FFoU+bejZYxgkz36Hc+nOeSQWkRPEDFoorbVGiB7+hsXuun8UCSb p2clguM5ErlthHAEZp9Z7nZft3MYYKD4kUxgjFymL2MaO4+cWDtGdlZn33j0CDnLXdFMe oOm07i1WjmDB1It+1YlVDhNRhVfSD2or6A/In8ZOCjSKi+YAXbJdF5Fwvaib5eb+rBZwr /xhgkuLbft+w6seNv/s5zMIrZZBr3LHzbtRHLzlMzvFW21ygEZKlIkOW4Xsw5oG15VfY5 XjBaHuE9XorU6QIHrCFt09hUluNaOdkErFKIZbFvawOBG2dXpjWDlWPXnhTHY5HeDNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387559; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ReZdgq5cbKCN/fFcPL8XScByoGRgJ18ZfjR2LyoD0oA=; b=FrG0l/hnDwh2mcgyGFAZreNZ0yggnIro4CRCPPsc+6/QN04DTkwiU1k7iaDU2lY+2hsm hOOGFeU6JBBiNfzqNYrExkIJ9HGQXlS2LcxnIxPbczYU00h7twq7+EolD3GjhDsrMibSZ DHvVHtlQBB/B2wLBOa4V4R6xRiQUnC/ADe6Tk57dL+9Uo9vxB9H7K5VOsl1biI3PWCENC HfSTFMOiG5qrkbrJnbpeZMHmCSIO6eml0Mn4G5cX0afcilyVuko0WJ1kBnjPxILg1WAit 3ecdZs+iHFXQM65tjiGxAD3WLC5a1KCG8QAobunhIHWidt7m+Ka99Q/pa7Zt9Sjs15g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=prF38Mwg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0738606A322; Fri, 4 Dec 2026 12:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=prF38Mwg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27FE91F000C2; Fri, 4 Dec 2026 12:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387559; bh=ReZdgq5cbKCN/fFcPL8XScByoGRgJ18ZfjR2LyoD0oA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=prF38MwgA8bzSk+DOqdhffahkx4B35C2Tc5ywDqPd0NIdDXe89uiEY6j0yz/YMgHF QL67XPgD3krNwsXbo9mrEtzA/3iuz826vmoXxYQAaIoaeaIdjkPZF4yckA0dgRyyUl Ciy18SrEVuBPZXNg7ShDoJAub3OmjdCL6xY8p1sw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Sasha Levin Subject: [PATCH 6.1 0295/1059] serial: sh-sci: Unregister UART on sysfs setup failure Date: Fri, 4 Dec 2026 18:57:06 +0900 Message-ID: <20261204100651.920243933@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak [ Upstream commit c5b33c86d86da3ccff8c05e2a28719e3ec933f70 ] sci_probe_single() registers the UART port before sci_probe() creates the RX FIFO tuning attributes. If either device_create_file() call fails, probe returns an error without removing the port from the serial core. Device-managed resources are then released while the port remains registered. Unregister the UART port before returning either sysfs creation error. If the second attribute fails, remove the first attribute before unregistering the port. Keep the existing probe failure policy and leave the successful initialization path unchanged. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: 5d23188a473d ("serial: sh-sci: make RX FIFO parameters tunable via sysfs") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Link: https://patch.msgid.link/20260911031500.5745-1-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman [ sashal: Adjusted the hunk layout: the rx_fifo_timeout creation is a separate type-checked block rather than nested in a fifosize check, and its error path keeps the conditional trigger-file removal before jumping to the new err_remove_port label. ] Signed-off-by: Sasha Levin --- drivers/tty/serial/sh-sci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index eb69b56bb8215..3c84c0580a9ce 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3439,7 +3439,7 @@ static int sci_probe(struct platform_device *dev) if (sp->port.fifosize > 1) { ret = device_create_file(&dev->dev, &dev_attr_rx_fifo_trigger); if (ret) - return ret; + goto err_remove_port; } if (sp->port.type == PORT_SCIFA || sp->port.type == PORT_SCIFB || sp->port.type == PORT_HSCIF) { @@ -3449,7 +3449,7 @@ static int sci_probe(struct platform_device *dev) device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger); } - return ret; + goto err_remove_port; } } @@ -3459,6 +3459,10 @@ static int sci_probe(struct platform_device *dev) sci_ports_in_use |= BIT(dev_id); return 0; + +err_remove_port: + uart_remove_one_port(&sci_uart_driver, &sp->port); + return ret; } static void sci_console_save(struct sci_port *s) -- 2.53.0