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=1795937795; b=gguPB4n/Bxhs7f3dpGzANVLs6l2Lk+w/OJj2l7bTd1ZZ9MhImBCQKBeqlKF1mGhTsMHi yZzRbW+PxDg6yBr4Vq34mm/alJwm//4NKIccZ4KElZeA/JddKadDC02s4LwjYTby5LJIT JjRUQy5UJjpiGxI8Np78bNq/6500B9nbKcBvbCiskt5vUKhUD5R5K2GDuR7FBrMI/R5ro IffhYqbTGoshsV3TO/bWld1qGUVzG6VVE5vnk+qeFj9UnWLueYXbmpKldBWlsjlMuyYVw BWG3lE+WevmEuAwNYL2zSVb7VDUTn71qfe+boCpUdBzUcfCo+OwwBakYF/yjNcb7jrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795937795; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Srq/0zTeeaUsNVEGRTk4YN7rzqcnydydsapFh2y4mNw=; b=Ks4ZjidtcVGXge8wI1vHM6LiMDv3WKO7BYVZlzq3CtmFwzqpYJB+ggN38+TZJ1Amj4Im pVoK53OAmvI5IukivZLdniRCk4FoqpPp+S/9KWwaqp8ezhXHmx7afQ+LwmVVeAmbDT+io il+ov1Hg4G6+6IDR18iRkC/yGU8JQP8KlIgyyJ1Pcy974aKqIjBo3BT+v+1jlLkXBOGwR OerEZgdAUu+etEOhrIG13uAR4xXXq0nZ0F5zrELK0iTIoDokyP4xOnG8jfIZger15BXbE 6mcSCQkwOHUPtVAeWLk9BvVZiAJN6EMIWiyZ3pVuULQZe//LRW2T+m4bq1sXlfj4EqA== 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=MF+24Tta; 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 365D8606A31C for ; Sun, 29 Nov 2026 07:36:34 +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=MF+24Tta Received: by smtp.kernel.org (Postfix) with ESMTPSA id A13221F00896; Sun, 29 Nov 2026 07:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795937794; bh=Srq/0zTeeaUsNVEGRTk4YN7rzqcnydydsapFh2y4mNw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=MF+24TtaheVlD/7PtM0cka98YNcUEP7v0zB+5+uIm7u/ASr+Rzr7wZEOtuckI7v8M qG9Nl+BTFLnA1CM7jus7vN60qKOG5VHz64+N7CdwbuUgDfbZ1jZev/yr6SQZjhK4sY 3gmK3NGgDz2H0r5zA86T8OA5vTywsSqYp091X6l1R/tOwnA3X8NRWp6h2bcgstxtKn lNk+tEOsLZWIP5F6Le3E4TIWYb9yNANUslVejIjC6ABuUssoTU3WtGbVdOFdycZDey mLbbshrvn7he+2ctw7WhpH/QMeBzFCBiDPelvqh0haTcbKCli0u5XLLsDoZmWcD03e d/imFCqPA7FyQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] serial: mvebu-uart: disable the clock when probe fails Reply-To: sashiko-reviews@lists.linux.dev To: "Arina Kharlamova" Cc: linux-serial@vger.kernel.org In-Reply-To: <20261129-s2p-v08-v1-1-342b7170e692@mbzuai.ac.ae> References: <20261129-s2p-v08-v1-1-342b7170e692@mbzuai.ac.ae> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 07:36:34 +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 no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] serial: mvebu-uart: stale global port state on mvebu_uart_probe() error [1] -- commit 98c494846856773a61ec6f57e5851a44337bc3b6 Author: Arina Kharlamova serial: mvebu-uart: disable the clock when probe fails This commit registers a devres action to disable and unprepare the UART clock when mvebu_uart_probe() fails or defers after enabling it. > diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-u= art.c > index 8a61517d81f21..d344ad2023a37 100644 > --- a/drivers/tty/serial/mvebu-uart.c > +++ b/drivers/tty/serial/mvebu-uart.c > @@ -864,6 +864,11 @@ static const struct of_device_id mvebu_uart_of_match= []; > /* Counter to keep track of each UART port id when not using CONFIG_OF */ > static int uart_num_counter; > =20 > +static void mvebu_uart_clk_disable(void *data) > +{ > + clk_disable_unprepare(data); > +} > + > static int mvebu_uart_probe(struct platform_device *pdev) > { > const struct of_device_id *match =3D of_match_device(mvebu_uart_of_matc= h, > @@ -871,7 +876,7 @@ static int mvebu_uart_probe(struct platform_device *p= dev) > struct uart_port *port; > struct mvebu_uart *mvuart; > struct resource *reg; > - int id, irq; > + int id, irq, ret; > =20 > /* Assume that all UART ports have a DT alias or none has */ > id =3D of_alias_get_id(pdev->dev.of_node, "serial"); > @@ -935,8 +940,14 @@ static int mvebu_uart_probe(struct platform_device *= pdev) > return PTR_ERR(mvuart->clk); > } > } else { > - if (!clk_prepare_enable(mvuart->clk)) > + if (!clk_prepare_enable(mvuart->clk)) { > + ret =3D devm_add_action_or_reset(&pdev->dev, > + mvebu_uart_clk_disable, > + mvuart->clk); > + if (ret) > + return ret; > port->uartclk =3D clk_get_rate(mvuart->clk); > + } > } > =20 > /* Manage interrupts */ [Severity: High] This problem wasn't introduced by this patch, but can returning on an error or probe deferral in mvebu_uart_probe() leave dangling pointers in the global mvebu_uart_ports[] array [1]? Before fetching the clock or interrupts, mvebu_uart_probe() populates mvebu_uart_ports[pdev->id] with devres-managed allocations: drivers/tty/serial/mvebu-uart.c:mvebu_uart_probe() { ... port =3D &mvebu_uart_ports[pdev->id]; ... 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; mvuart =3D devm_kzalloc_obj(&pdev->dev, struct mvebu_uart); if (!mvuart) return -ENOMEM; ... port->private_data =3D mvuart; ... } If a later step fails or defers (for example, devm_clk_get() or platform_get_irq() returning -EPROBE_DEFER), devres unmaps port->membase and frees mvuart, while mvebu_uart_ports[pdev->id] keeps the non-NULL port->membase, non-zero port->mapbase, and freed port->private_data. Because mvebu_uart_console_setup() only checks !port->mapbase || !port->membase before calling uart_set_options(), console setup on the unprobed port will dereference freed memory in port->private_data and access unmapped MMIO at port->membase. In addition, when no DT serial alias is present, pdev->id is assigned from uart_num_counter++, which is not rolled back on probe deferral and can exhaust MVEBU_NR_UARTS across retries. [1] https://sashiko.dev/#/bug/linux-289cf5cf-e5b0-49b1-9858-4b240bfa4c46 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-s2p-v08-v1= -1-342b7170e692@mbzuai.ac.ae?part=3D1