create_proc_profile() returns 0 whether proc_create() worked or not, so
a write to /sys/kernel/profiling that turned profiling on but didn't
get the file reports success and there is no file to read the profile
from. Return -ENOMEM like the other failures of that write do.

Fixes: 22b8ce94708f ("profiling: dynamically enable readprofile at runtime")
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 kernel/profile.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index e7defa90a34c..820d5ec909d4 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -216,15 +216,15 @@ static const struct proc_ops profile_proc_ops = {
 int __ref create_proc_profile(void)
 {
        struct proc_dir_entry *entry;
-       int err = 0;
 
        if (!prof_on)
                return 0;
        entry = proc_create("profile", S_IWUSR | S_IRUGO,
                            NULL, &profile_proc_ops);
-       if (entry)
-               proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
-       return err;
+       if (!entry)
+               return -ENOMEM;
+       proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
+       return 0;
 }
 subsys_initcall(create_proc_profile);
 #endif /* CONFIG_PROC_FS */

-- 
2.53.0

Reply via email to