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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190524143355.5586D2133D@mail.kernel.org>
Date:   Fri, 24 May 2019 07:33:54 -0700
From:   Stephen Boyd <sboyd@...nel.org>
To:     Alexandre Mergnat <amergnat@...libre.com>, mturquette@...libre.com
Cc:     linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
        baylibre-upstreaming@...ups.io,
        Alexandre Mergnat <amergnat@...libre.com>,
        Jerome Brunet <jbrunet@...libre.com>
Subject: Re: [PATCH] clk: fix clock global name usage.

Quoting Alexandre Mergnat (2019-05-24 00:27:45)
> A recent patch allows the clock framework to specify the parent
> relationship with either the clk_hw pointer, the global name or through
> Device Tree name.

You could point to the commit instead of saying "a recent patch". Would
provide more clarity.

> 
> But the global name isn't handled by the clk framework because the DT name
> is considered valid even if it's NULL, so of_clk_get_hw() returns an
> unexpected clock (the first clock specified in DT).

Yes, the DT name can be NULL and then we would use the index.

> 
> This can be fixed by calling of_clk_get_hw() only when DT name is not NULL.
> 
> Fixes: fc0c209c147f ("clk: Allow parents to be specified without string names")
> Cc: Jerome Brunet <jbrunet@...libre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@...libre.com>
> ---
>  drivers/clk/clk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index bdb077ba59b9..9624a75e5a8d 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -368,7 +368,7 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index)
>         const char *dev_id = dev ? dev_name(dev) : NULL;
>         struct device_node *np = core->of_node;
>  
> -       if (np && index >= 0)
> +       if (name && np && index >= 0)

Do you set the index to 0 in this clk's parent_data? We purposefully set
the index to -1 in clk_core_populate_parent_map() so that the fw_name
can be NULL but the index can be something >= 0 and then we'll use that
to lookup the clk from DT. We need to support that combination.

	fw_name   |   index |  DT lookup?
	----------+---------+------------
	NULL      |    >= 0 |     Y
	NULL      |    -1   |     N
	non-NULL  |    -1   |     ?
	non-NULL  |    >= 0 |     Y

Maybe we should support the ? case, because right now it will fail to do
the DT lookup when the index is -1.

So this patch instead?

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b34e84bb8167..a554cb9316a5 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -368,7 +368,7 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index)
 	const char *dev_id = dev ? dev_name(dev) : NULL;
 	struct device_node *np = core->of_node;
 
-	if (np && index >= 0)
+	if (np && (index >= 0 || name))
 		hw = of_clk_get_hw(np, index, name);
 
 	/*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ