clk: convert clock name allocations to kstrdup_const
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 13 Feb 2015 22:36:33 +0000 (14:36 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:36 +0000 (21:21 -0800)
Clock subsystem frequently performs duplication of strings located in
read-only memory section.  Replacing kstrdup by kstrdup_const allows to
avoid such operations.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg KH <greg@kroah.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/clk/clk.c

index d48ac71c6c8b173793a31e95ebaa93749e883a76..642cf37124d3780024d1739bf9298aa788c336e2 100644 (file)
@@ -2048,7 +2048,7 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
                goto fail_out;
        }
 
-       clk->name = kstrdup(hw->init->name, GFP_KERNEL);
+       clk->name = kstrdup_const(hw->init->name, GFP_KERNEL);
        if (!clk->name) {
                pr_err("%s: could not allocate clk->name\n", __func__);
                ret = -ENOMEM;
@@ -2075,7 +2075,7 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
 
        /* copy each string name in case parent_names is __initdata */
        for (i = 0; i < clk->num_parents; i++) {
-               clk->parent_names[i] = kstrdup(hw->init->parent_names[i],
+               clk->parent_names[i] = kstrdup_const(hw->init->parent_names[i],
                                                GFP_KERNEL);
                if (!clk->parent_names[i]) {
                        pr_err("%s: could not copy parent_names\n", __func__);
@@ -2090,10 +2090,10 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
 
 fail_parent_names_copy:
        while (--i >= 0)
-               kfree(clk->parent_names[i]);
+               kfree_const(clk->parent_names[i]);
        kfree(clk->parent_names);
 fail_parent_names:
-       kfree(clk->name);
+       kfree_const(clk->name);
 fail_name:
        kfree(clk);
 fail_out:
@@ -2112,10 +2112,10 @@ static void __clk_release(struct kref *ref)
 
        kfree(clk->parents);
        while (--i >= 0)
-               kfree(clk->parent_names[i]);
+               kfree_const(clk->parent_names[i]);
 
        kfree(clk->parent_names);
-       kfree(clk->name);
+       kfree_const(clk->name);
        kfree(clk);
 }