]> Pileus Git - ~andy/linux/commitdiff
clk: get matching entry under lock in of_clk_init()
authorAlex Elder <alex.elder@linaro.org>
Thu, 22 Aug 2013 16:31:31 +0000 (11:31 -0500)
committerMike Turquette <mturquette@linaro.org>
Tue, 27 Aug 2013 23:05:39 +0000 (16:05 -0700)
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>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk.c

index 7c4376289865ee587f6ac3ea3d2b1866a6b10f52..2db08c01ef51d9de9b618282ba55134d97dfabe4 100644 (file)
@@ -2228,13 +2228,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);
        }