clk: Fix debugfs_create_*() usage
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 3 Jan 2018 11:06:15 +0000 (12:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 06:01:02 +0000 (08:01 +0200)
commit 4c8326d5ebb0de3191e98980c80ab644026728d0 upstream.

When exposing data access through debugfs, the correct
debugfs_create_*() functions must be used, matching the data
types.

Remove all casts from data pointers passed to debugfs_create_*()
functions, as such casts prevent the compiler from flagging bugs.

clk_core.rate and .accuracy are "unsigned long", hence casting
their addresses to "u32 *" exposed the wrong halves on big-endian
64-bit systems. Fix this by using debugfs_create_ulong() instead.

Octal permissions are preferred, as they are easier to read than
symbolic permissions. Hence replace "S_IRUGO" by "0444"
throughout.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[sboyd@codeaurora.org: Squash the octal change in too]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/clk.c

index 8341a128dab1db5f27a9f60582a7d6574311b48c..44b6f23cc851d6c37a611aef3a5077673099facd 100644 (file)
@@ -2172,18 +2172,16 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 
        core->dentry = d;
 
-       d = debugfs_create_u32("clk_rate", S_IRUGO, core->dentry,
-                       (u32 *)&core->rate);
+       d = debugfs_create_ulong("clk_rate", 0444, core->dentry, &core->rate);
        if (!d)
                goto err_out;
 
-       d = debugfs_create_u32("clk_accuracy", S_IRUGO, core->dentry,
-                       (u32 *)&core->accuracy);
+       d = debugfs_create_ulong("clk_accuracy", 0444, core->dentry,
+                                &core->accuracy);
        if (!d)
                goto err_out;
 
-       d = debugfs_create_u32("clk_phase", S_IRUGO, core->dentry,
-                       (u32 *)&core->phase);
+       d = debugfs_create_u32("clk_phase", 0444, core->dentry, &core->phase);
        if (!d)
                goto err_out;
 
@@ -2192,23 +2190,23 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
        if (!d)
                goto err_out;
 
-       d = debugfs_create_u32("clk_prepare_count", S_IRUGO, core->dentry,
-                       (u32 *)&core->prepare_count);
+       d = debugfs_create_u32("clk_prepare_count", 0444, core->dentry,
+                              &core->prepare_count);
        if (!d)
                goto err_out;
 
-       d = debugfs_create_u32("clk_enable_count", S_IRUGO, core->dentry,
-                       (u32 *)&core->enable_count);
+       d = debugfs_create_u32("clk_enable_count", 0444, core->dentry,
+                              &core->enable_count);
        if (!d)
                goto err_out;
 
-       d = debugfs_create_u32("clk_notifier_count", S_IRUGO, core->dentry,
-                       (u32 *)&core->notifier_count);
+       d = debugfs_create_u32("clk_notifier_count", 0444, core->dentry,
+                              &core->notifier_count);
        if (!d)
                goto err_out;
 
        if (core->num_parents > 1) {
-               d = debugfs_create_file("clk_possible_parents", S_IRUGO,
+               d = debugfs_create_file("clk_possible_parents", 0444,
                                core->dentry, core, &possible_parents_fops);
                if (!d)
                        goto err_out;
@@ -2304,22 +2302,22 @@ static int __init clk_debug_init(void)
        if (!rootdir)
                return -ENOMEM;
 
-       d = debugfs_create_file("clk_summary", S_IRUGO, rootdir, &all_lists,
+       d = debugfs_create_file("clk_summary", 0444, rootdir, &all_lists,
                                &clk_summary_fops);
        if (!d)
                return -ENOMEM;
 
-       d = debugfs_create_file("clk_dump", S_IRUGO, rootdir, &all_lists,
+       d = debugfs_create_file("clk_dump", 0444, rootdir, &all_lists,
                                &clk_dump_fops);
        if (!d)
                return -ENOMEM;
 
-       d = debugfs_create_file("clk_orphan_summary", S_IRUGO, rootdir,
+       d = debugfs_create_file("clk_orphan_summary", 0444, rootdir,
                                &orphan_list, &clk_summary_fops);
        if (!d)
                return -ENOMEM;
 
-       d = debugfs_create_file("clk_orphan_dump", S_IRUGO, rootdir,
+       d = debugfs_create_file("clk_orphan_dump", 0444, rootdir,
                                &orphan_list, &clk_dump_fops);
        if (!d)
                return -ENOMEM;