lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aSgUQvExNY2lCpYT@smile.fi.intel.com>
Date: Thu, 27 Nov 2025 11:05:06 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: wenhua lin <wenhua.lin1994@...il.com>
Cc: Wenhua Lin <Wenhua.Lin@...soc.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Jiri Slaby <jirislaby@...nel.org>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Orson Zhai <orsonzhai@...il.com>,
	Baolin Wang <baolin.wang@...ux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@...il.com>,
	Cixi Geng <cixi.geng@...ux.dev>, linux-kernel@...r.kernel.org,
	linux-serial@...r.kernel.org,
	Xiongpeng Wu <xiongpeng.wu@...soc.com>,
	Zhaochen Su <Zhaochen.Su@...soc.com>,
	Zhirong Qiu <Zhirong.Qiu@...soc.com>
Subject: Re: [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is
 not ready

On Thu, Nov 27, 2025 at 04:44:08PM +0800, wenhua lin wrote:
> On Wed, Nov 26, 2025 at 8:57 PM Andy Shevchenko
> <andriy.shevchenko@...el.com> wrote:
> > On Wed, Oct 22, 2025 at 11:08:40AM +0800, Wenhua Lin wrote:

...

> > >       clk_uart = devm_clk_get(uport->dev, "uart");
> > >       if (IS_ERR(clk_uart)) {
> > > +             if (PTR_ERR(clk_uart) == -EPROBE_DEFER)
> > > +                     return -EPROBE_DEFER;
> > > +
> > >               dev_warn(uport->dev, "uart%d can't get uart clock\n",
> > >                        uport->line);
> > >               clk_uart = NULL;
> >
> > AFAICS this still ignores other issues, what should be done here is to
> > replace devm_clk_get() by devm_clk_get_optional() and drop this NULL
> > assignment.

>    The main reason for this change is that the UART driver is
> built-in, while the CLK driver is loaded as a module (ko).
>    There may be a situation where the UART driver is loaded first. If
> an EPROBE_DEFER error occurs, the driver will return directly
>    and continue waiting for the CLK driver to complete loading.
>    If this interface is changed to devm_clk_get_optional, in scenarios
> where dependent components are not yet loaded,
>    it will no longer return EPROBE_DEFER but instead return null. This
> behavior may not align with the desired outcome.

No, the _optional does exactly what your code does with the better approach
that may return other errors _in addition to_ the current state of affairs.

So, please switch to _optional variant and drop all that unneeded dances.

	clk_uart = devm_clk_get_optional(uport->dev, "uart");
	if (IS_ERR(clk_uart)) {
		return dev_err_probe(uport->dev, PTR_ERR(clk_uart),
				     "uart%d can't get uart clock\n", uport->line);

this will return an error when clock is present, but can't be retrieved.
When there is no clock provided at all, it will return NULL.

> > >       clk_parent = devm_clk_get(uport->dev, "source");
> > >       if (IS_ERR(clk_parent)) {
> > > +             if (PTR_ERR(clk_parent) == -EPROBE_DEFER)
> > > +                     return -EPROBE_DEFER;
> > > +
> > >               dev_warn(uport->dev, "uart%d can't get source clock\n",
> > >                        uport->line);
> > >               clk_parent = NULL;

Ditto.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ