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=1796153416; b=b/8Qkgy/qohH0FDO0iZECIdeuIF99sb5sAT5ckVqayMufuWmNSIxeUcShfSeUVBWaSL9 u/QAWz6+51iEIAXIm2bJP6NOT+cXYRpEVyiHBs0fj4FdrEqZ18GAxRlHf++V/sbMGm1yb ge+xxUJk07/dpr4uB5LV44cpNJIxP7FSSVWFyYebrl/83Zwyx/9UebWdXMQbPWp6QcELL F95e4npLgN4HZu68B7j4CNz9LDEPa45pvXmN/fVTn2q32vmNjDQMHUsWkwL9kceF1E88S 1UmpldFuOC64Ug5KkvgiSJcWBOMPMYyPIXv38G0dda/CqfE303hTAfIEe0J+pA50LNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796153416; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8jy4rkfVNt2Bq939nRfawRZunh5g6/LaiRbDqjnEeTk=; b=sLxyWFc4JyfKKhTm6fXK9fxZ8BdtgrE+oqqk/eAIqo4donkwL3QV1yCopTz12UocxKFj iyt9pnua2JYI3AHZlmC20ZZahWBoYG8YzIdNv3XeQdFPzstBlD/MjEwC7aCWVdnKLu9Hd K2iTzZpMOqASsOVMyUSm6VP17k4OGxrzxp8L8rqGHyTzridd9lqNImdQBTXMU3rxPOpEr n/nOk7mkJB+tjkgsTt+zqMFHimwM/GdC179Z1FNSuCfcMWMqFnhCSrdL/r88dE5ioA9wT bzcjz6p6DSSY3TTnJN1DniTrz6Jr1NKYcKWXfomaK6gv9eh0+L31rB6uEDdwFMdoQ4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eMqQOjmH; 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 07C49606A68D for ; Tue, 1 Dec 2026 19:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eMqQOjmH Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB1A61F0089C; Tue, 1 Dec 2026 19:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796153415; bh=8jy4rkfVNt2Bq939nRfawRZunh5g6/LaiRbDqjnEeTk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eMqQOjmHoWHc4mwGesBJOkathvm8SBYK4XizgYejO5kbrDR9/dCRMl8tBuYEoBCpJ +jlu9A28Xf9iBG0CIvFne7wp5hwOnEF+3L5xBlL6P3uE9DsaQtzp1UuaNgXSUi1Glm VLvBYY95VcEk8I6OEa4plOSiOVpwww+TifdRN/W9TqIc/FVLKG4DyDAOMnxa7QlIcd 0FHmeA+nVbuQG3lgPz3m9SrSSrFVifxxY2uYrWep6at0t1JWMtZxt826mbZJK1YP0A BZoUJyZLtc91k/2NTYQWzNQRM7NGy5xyzm/uS0l4ZiiVmkvf1YaNvHXG56OTvNC5mQ 2iw/w3+QrzZEg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] serial: mvebu-uart: do not leave a stale port behind when probe fails Reply-To: sashiko-reviews@lists.linux.dev To: "Arina Kharlamova" Cc: linux-serial@vger.kernel.org In-Reply-To: <20261201-v08b-v1-1-add40eb9ffee@mbzuai.ac.ae> References: <20261201-v08b-v1-1-add40eb9ffee@mbzuai.ac.ae> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 19:30:14 +0000 X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] serial: mvebu-uart: stale port pointers left on mvebu_uart_probe() failure -- commit d1e6578bd1896e971560b8acbf90f40f07f54907 Author: Arina Kharlamova serial: mvebu-uart: do not leave a stale port behind when probe fails This commit defers storing membase and mapbase in the static mvebu_uart_ports[] entry until after clock and interrupt acquisition in mvebu_uart_probe(). > diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-u= art.c > index 8a61517d81f21..9f59fa5a706e0 100644 > --- a/drivers/tty/serial/mvebu-uart.c > +++ b/drivers/tty/serial/mvebu-uart.c > @@ -868,6 +868,7 @@ static int mvebu_uart_probe(struct platform_device *p= dev) > { > const struct of_device_id *match =3D of_match_device(mvebu_uart_of_matc= h, > &pdev->dev); > + void __iomem *base; > struct uart_port *port; > struct mvebu_uart *mvuart; > struct resource *reg; > @@ -908,10 +909,9 @@ static int mvebu_uart_probe(struct platform_device *= pdev) > port->irq =3D 0; > port->irqflags =3D 0; > =20 > - port->membase =3D devm_platform_get_and_ioremap_resource(pdev, 0, ®); > - if (IS_ERR(port->membase)) > - return PTR_ERR(port->membase); > - port->mapbase =3D reg->start; > + base =3D devm_platform_get_and_ioremap_resource(pdev, 0, ®); > + if (IS_ERR(base)) > + return PTR_ERR(base); > =20 > mvuart =3D devm_kzalloc_obj(&pdev->dev, struct mvebu_uart); > if (!mvuart) > @@ -966,6 +966,9 @@ static int mvebu_uart_probe(struct platform_device *p= dev) > mvuart->irq[UART_TX_IRQ] =3D irq; > } > =20 > + port->membase =3D base; > + port->mapbase =3D reg->start; [Severity: Medium] Can mvebu_uart_probe() still leave stale pointers in mvebu_uart_ports[] if uart_add_one_port() fails, or leave a dangling port->private_data if clock or IRQ acquisition fails? If uart_add_one_port() returns an error before configuring the console, devres unmaps base and frees mvuart while port->membase, port->mapbase and port->private_data remain set in the static mvebu_uart_ports[] array. If another port later registers the console, mvebu_uart_console_setup() sees non-zero mapbase and membase and calls uart_set_options() -> mvebu_uart_set_termios(), causing a use-after-free on port->private_data and an access to unmapped MMIO at port->membase. In addition, port->private_data =3D mvuart is still assigned before devm_clk_get() and platform_get_irq(), so a clock or interrupt deferral still leaves a dangling private_data pointer in mvebu_uart_ports[]. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-v08b-v1-1-= add40eb9ffee@mbzuai.ac.ae?part=3D1