mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kernel: profile: fix error return code of create_proc_profile()
@ 2021-03-09  9:02 Jia-Ju Bai
  2021-03-09  9:32 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-03-09  9:02 UTC (permalink / raw)
  To: bigeasy; +Cc: linux-kernel, Jia-Ju Bai

When proc_create() returns NULL to entry, no error return code of
create_proc_profile() is assigned.
To fix this bug, err is assigned with -ENOMEM in this case.

Fixes: e722d8daafb9 ("profile: Convert to hotplug state machine")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 kernel/profile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index 6f69a4195d56..65bf03bb8a5e 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -549,8 +549,10 @@ int __ref create_proc_profile(void)
 #endif
 	entry = proc_create("profile", S_IWUSR | S_IRUGO,
 			    NULL, &profile_proc_ops);
-	if (!entry)
+	if (!entry) {
+		err = -ENOMEM;
 		goto err_state_onl;
+	}
 	proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
 
 	return err;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel: profile: fix error return code of create_proc_profile()
  2021-03-09  9:02 [PATCH] kernel: profile: fix error return code of create_proc_profile() Jia-Ju Bai
@ 2021-03-09  9:32 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-03-09  9:32 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, Peter Zijlstra

On 2021-03-09 01:02:15 [-0800], Jia-Ju Bai wrote:
> When proc_create() returns NULL to entry, no error return code of
> create_proc_profile() is assigned.
> To fix this bug, err is assigned with -ENOMEM in this case.

I preserved what was in commit
    c270a817196a9 ("profile: Fix CPU hotplug callback registration")

which was already in commit
    c33fff0afbef4 ("kernel: use non-racy method for proc entries creation")

and goes back to its original introduction in history tree's commit
    423284ee6eb52 ("[PATCH] consolidate prof_cpu_mask")

which is ignoring a failure here.
If we decide otherwise and not ignore the error then it would be good to
use an earlier commit so the change also makes into v4.4+ stable.

> Fixes: e722d8daafb9 ("profile: Convert to hotplug state machine")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  kernel/profile.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 6f69a4195d56..65bf03bb8a5e 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -549,8 +549,10 @@ int __ref create_proc_profile(void)
>  #endif
>  	entry = proc_create("profile", S_IWUSR | S_IRUGO,
>  			    NULL, &profile_proc_ops);
> -	if (!entry)
> +	if (!entry) {
> +		err = -ENOMEM;
>  		goto err_state_onl;
> +	}
>  	proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
>  
>  	return err;

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-09  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  9:02 [PATCH] kernel: profile: fix error return code of create_proc_profile() Jia-Ju Bai
2021-03-09  9:32 ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®