* [PATCH] clk: get matching entry under lock in of_clk_init()
@ 2013-08-09 13:16 Alex Elder
2013-08-22 16:31 ` [PATCH, resend] " Alex Elder
0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2013-08-09 13:16 UTC (permalink / raw
To: linux-arm-kernel
Currently of_clk_init() finds a matching device node while holding
the device tree spinlock. When a matching device node is found, the
lock is dropped and then re-acquired in order to get a reference
to the matching device id structure.
Acquiring the spinlock twice is unnecessary (and it opens a
vulnerable window that could conceivably lead to errors).
There already exists an interface for both finding and taking a
reference to a device id under lock, so use it.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Christian Daudt <csd@broadcom.com>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
drivers/clk/clk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 56a00db..760ab1d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2116,13 +2116,13 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
*/
void __init of_clk_init(const struct of_device_id *matches)
{
+ const struct of_device_id *match;
struct device_node *np;
if (!matches)
matches = __clk_of_table;
- for_each_matching_node(np, matches) {
- const struct of_device_id *match = of_match_node(matches, np);
+ for_each_matching_node_and_match(np, matches, &match) {
of_clk_init_cb_t clk_init_cb = match->data;
clk_init_cb(np);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH, resend] clk: get matching entry under lock in of_clk_init()
2013-08-09 13:16 [PATCH] clk: get matching entry under lock in of_clk_init() Alex Elder
@ 2013-08-22 16:31 ` Alex Elder
2013-08-27 23:06 ` Mike Turquette
0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2013-08-22 16:31 UTC (permalink / raw
To: linux-arm-kernel
Currently of_clk_init() finds a matching device node while holding
the device tree spinlock. When a matching device node is found, the
lock is dropped and then re-acquired in order to get a reference
to the matching device id structure.
Acquiring the spinlock twice is unnecessary (and it opens a
vulnerable window that could conceivably lead to errors).
There already exists an interface for both finding and taking a
reference to a device id under lock, so use it.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Christian Daudt <csd@broadcom.com>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
drivers/clk/clk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 56a00db..760ab1d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2116,13 +2116,13 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
*/
void __init of_clk_init(const struct of_device_id *matches)
{
+ const struct of_device_id *match;
struct device_node *np;
if (!matches)
matches = __clk_of_table;
- for_each_matching_node(np, matches) {
- const struct of_device_id *match = of_match_node(matches, np);
+ for_each_matching_node_and_match(np, matches, &match) {
of_clk_init_cb_t clk_init_cb = match->data;
clk_init_cb(np);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH, resend] clk: get matching entry under lock in of_clk_init()
2013-08-22 16:31 ` [PATCH, resend] " Alex Elder
@ 2013-08-27 23:06 ` Mike Turquette
0 siblings, 0 replies; 3+ messages in thread
From: Mike Turquette @ 2013-08-27 23:06 UTC (permalink / raw
To: linux-arm-kernel
Quoting Alex Elder (2013-08-22 09:31:31)
> Currently of_clk_init() finds a matching device node while holding
> the device tree spinlock. When a matching device node is found, the
> lock is dropped and then re-acquired in order to get a reference
> to the matching device id structure.
>
> Acquiring the spinlock twice is unnecessary (and it opens a
> vulnerable window that could conceivably lead to errors).
>
> There already exists an interface for both finding and taking a
> reference to a device id under lock, so use it.
>
> Signed-off-by: Alex Elder <elder@linaro.org>
> Reviewed-by: Christian Daudt <csd@broadcom.com>
> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> Reviewed-by: Matt Porter <matt.porter@linaro.org>
Thanks for the fix. Taken into clk-next.
Regards,
Mike
> ---
> drivers/clk/clk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 56a00db..760ab1d 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2116,13 +2116,13 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
> */
> void __init of_clk_init(const struct of_device_id *matches)
> {
> + const struct of_device_id *match;
> struct device_node *np;
>
> if (!matches)
> matches = __clk_of_table;
>
> - for_each_matching_node(np, matches) {
> - const struct of_device_id *match = of_match_node(matches, np);
> + for_each_matching_node_and_match(np, matches, &match) {
> of_clk_init_cb_t clk_init_cb = match->data;
> clk_init_cb(np);
> }
> --
> 1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-27 23:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-09 13:16 [PATCH] clk: get matching entry under lock in of_clk_init() Alex Elder
2013-08-22 16:31 ` [PATCH, resend] " Alex Elder
2013-08-27 23:06 ` Mike Turquette
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.