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=1796384889; b=E0VBsRoLLMEgm16wEWMhGOCNmjfbuw1EjthFMSZLjKKgrqszGIqNli/tHQe5wHNQ/S53 XPkV6npbYob84Bv99Q+AD2w71+dvUijSOlauXuQ37NVQuf8nuP7Cl50Y3cLfP1wJkgcru cSIBCu9Gb8JTGWQBL3lcTN2+9y8xSY15oVskzhFh8GFrKJuCY5F78D12Z+Xd4ytS9WN++ i/udG+5pC8TxzcNf1TsUzJS+LLc5Af32BaZEpppv4XuntCIjJ32zf1PhHT6zQYfvhlVa8 mn2rLwymMZ9KbbL8otfAGSNlkNiI9FsWR6r1i1LMG7P90ilOjD573S3PtuJ/mFPsD1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384889; 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=gnmzQZedv699fFEw3XnsJn50ImuTi+blZfRIRjuv4qM=; b=IokIjL4LO42wpg7/hqagoXbsEeRd/j4081mn0GAPKEypUGYZ4Wtfq0FkD7Wgm5fMCm36 5WXVRs4m9kSF9Qq8SPvJX3e1vm7Lev3EvQSSJvhdzRUd2IIc83SM+Up3IiS1TEanucMrb HzU2PRkRp9LKnucuse77ULst+F2LyVz4HhZiYr6m7U0cFo347FHKxk2iiTTZBwVauvwrQ HVNwNR9F2XceAM/9RDLMETWlNqCfYkpsEINjUcPXU7xtg1ary4CpBiQ8AXfykTzJSvDPb mZz2GIYLn0k1D82Mr02ygqf8JMHkGM9ZdzJmRuv0x3xlVHD4mjtFvll8uWe/OhDcvyg== 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=m3NKhJdl; 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 48F08606A322; Fri, 4 Dec 2026 11:48:09 +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=m3NKhJdl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 653651F00897; Fri, 4 Dec 2026 11:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384888; bh=gnmzQZedv699fFEw3XnsJn50ImuTi+blZfRIRjuv4qM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m3NKhJdlkB0hJMZmJgLTAeRHt8ScmXkNWGymra2ao+1Egrk+p4azecd5PK4qzT3rv RZg2zb61MA0geWpdQmaWfnpz9SRUsi3zpoloKPG/DJrWxR9rNFM2LswcqpJxNl1cX6 iA88m431Dc9bt4faTBpUYygonFbBG8eAwBfgwik8= 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.6 0337/1167] serial: sh-sci: Unregister UART on sysfs setup failure Date: Fri, 4 Dec 2026 18:56:04 +0900 Message-ID: <20261204100710.775058860@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: Split the single upstream hunk into two, since this tree has two separate if blocks for the sysfs attributes, and adjusted the trailing context because a different function follows sci_probe(). ] 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 4becdd1b90f92..bbd0d0ae782b2 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3512,7 +3512,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) { @@ -3522,7 +3522,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; } } @@ -3532,6 +3532,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