From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6F7B21B4254; Wed, 19 Feb 2025 17:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739987395; cv=none; b=ir7RbxalP5A8+Ta8E60WvFqz95tksnzm8Z/bEn8S8gdE4bSri10yzsm/JEY+1NfsNJLZAlzaJB15aV2s4LIzwcAo5kn9lFLlyC0Nvmmby5YX+Lk313ZcJiQ5eWRxcL3vvCWhXoz46UYKhcAekx+UmEn4Vt1/GmMHM6oT4IYqbWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739987395; c=relaxed/simple; bh=1QVCszsYwoEV4SPD2Ug+XLQ1X9GAtUaPJJ4JsX4DaVo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ANL5d593VSCPD8EoenhVeLXFmSXDa6QqLa4LuRxg4EwIivBtVSOOiAJrf4s2gcZDl84K3Uxl6crA1rymUDRsUY4J7pO/r/3Rkzukra1HXM5ykSiZ08g8CJuogwNjGml09M5+7RIOVqSBkhS2JQ80MoHfQ/fJNv06zQRWpNxrGpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VU6TvLGm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VU6TvLGm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A33DC4CED1; Wed, 19 Feb 2025 17:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739987394; bh=1QVCszsYwoEV4SPD2Ug+XLQ1X9GAtUaPJJ4JsX4DaVo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VU6TvLGm787LfvptS0TTvQUlSL9tWTKitMKogssmsUzNve619B3DbmezGV7OUvYD1 j1CF/mlah6lrCOqVRSgVXTuGHxZvZkqaO/9OaG0R9rNRNXTVemqrNFgruLw6wp3VN5 NqlXTgk9UzzloT/l6FNlGjeSa7JS/0uinbWLuQnGJvj4Qz84WAlgfuNvrc9M++btps jVAKdCXzTWfIpzkgnvmKyHkpxBEtLu+2ZkYsRlCp36apwuwxxQbhKbgDMCzqQ6FDav Koq33Va+CB8sus9jqhKzqWj855suAg352tPs9QAbz9G+CYhwkk+AXOyJCafOdGWQLr hMO67dR3MFGnA== Date: Wed, 19 Feb 2025 23:19:44 +0530 From: Manivannan Sadhasivam To: Vitalii Mordan Cc: Greg Kroah-Hartman , Jiri Slaby , Andreas =?utf-8?Q?F=C3=A4rber?= , Manivannan Sadhasivam , Jeff Johnson , Sebastian Andrzej Siewior , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Amit Singh Tomar , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, Fedor Pchelkin , Alexey Khoroshilov , Vadim Mutilin , lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: Re: [PATCH] tty: owl-uart: fix call balance of owl_port->clk handling routines Message-ID: <20250219174944.l3xdxrdy4lbkevw3@thinkpad> References: <20250213112416.1610678-1-mordan@ispras.ru> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250213112416.1610678-1-mordan@ispras.ru> On Thu, Feb 13, 2025 at 02:24:16PM +0300, Vitalii Mordan wrote: > If owl_port->clk was enabled in owl_uart_probe(), it must be disabled in > all error paths to ensure proper cleanup. However, if uart_add_one_port() > returns an error in owl_uart_probe(), the owl_port->clk clock will not be > disabled. > > Use the devm_clk_get_enabled() helper function to ensure proper call > balance for owl_port->clk. > > Found by Linux Verification Center (linuxtesting.org) with Klever. > > Fixes: abf42d2f333b ("tty: serial: owl: add "much needed" clk_prepare_enable()") > Cc: stable@vger.kernel.org > Signed-off-by: Vitalii Mordan Reviewed-by: Manivannan Sadhasivam - Mani > --- > drivers/tty/serial/owl-uart.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c > index 0542882cfbbe..64446820437c 100644 > --- a/drivers/tty/serial/owl-uart.c > +++ b/drivers/tty/serial/owl-uart.c > @@ -680,18 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev) > if (!owl_port) > return -ENOMEM; > > - owl_port->clk = devm_clk_get(&pdev->dev, NULL); > + owl_port->clk = devm_clk_get_enabled(&pdev->dev, NULL); > if (IS_ERR(owl_port->clk)) { > - dev_err(&pdev->dev, "could not get clk\n"); > + dev_err(&pdev->dev, "could not get and enable clk\n"); > return PTR_ERR(owl_port->clk); > } > > - ret = clk_prepare_enable(owl_port->clk); > - if (ret) { > - dev_err(&pdev->dev, "could not enable clk\n"); > - return ret; > - } > - > owl_port->port.dev = &pdev->dev; > owl_port->port.line = pdev->id; > owl_port->port.type = PORT_OWL; > @@ -701,7 +695,6 @@ static int owl_uart_probe(struct platform_device *pdev) > owl_port->port.uartclk = clk_get_rate(owl_port->clk); > if (owl_port->port.uartclk == 0) { > dev_err(&pdev->dev, "clock rate is zero\n"); > - clk_disable_unprepare(owl_port->clk); > return -EINVAL; > } > owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY; > @@ -725,7 +718,6 @@ static void owl_uart_remove(struct platform_device *pdev) > > uart_remove_one_port(&owl_uart_driver, &owl_port->port); > owl_uart_ports[pdev->id] = NULL; > - clk_disable_unprepare(owl_port->clk); > } > > static struct platform_driver owl_uart_platform_driver = { > -- > 2.25.1 > -- மணிவண்ணன் சதாசிவம்