* Re: [PATCH] fgraph: Fix missing unlock in register_ftrace_graph()
2024-10-23 17:04 [PATCH] fgraph: Fix missing unlock in register_ftrace_graph() Li Huafei
@ 2024-10-23 9:29 ` Steven Rostedt
2024-10-24 2:45 ` Li Huafei
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2024-10-23 9:29 UTC (permalink / raw)
To: Li Huafei
Cc: dan.carpenter, mhiramat, linux-kernel, linux-trace-kernel,
oe-kbuild, lkp
On Thu, 24 Oct 2024 01:04:48 +0800
Li Huafei <lihuafei1@huawei.com> wrote:
> Instead of returning an error, goto the mutex unlock at the end of the
> function.
>
> Fixes smatch warning:
>
> kernel/trace/fgraph.c:1317 register_ftrace_graph() warn: inconsistent returns '&ftrace_lock'.
>
> Fixes: 2c02f7375e65 ("fgraph: Use CPU hotplug mechanism to initialize idle shadow stacks")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202410220121.wxg0olfd-lkp@intel.com/
> Signed-off-by: Li Huafei <lihuafei1@huawei.com>
> ---
> kernel/trace/fgraph.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> index 41e7a15dcb50..98fa7b2a4903 100644
> --- a/kernel/trace/fgraph.c
> +++ b/kernel/trace/fgraph.c
> @@ -1259,7 +1259,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
> fgraph_cpu_init, NULL);
> if (ret < 0) {
> pr_warn("fgraph: Error to init cpu hotplug support\n");
> - return ret;
> + goto out;
> }
> fgraph_initialized = true;
> ret = 0;
Actually, I'm thinking we just should use guard(mutex)(&ftrace_lock);
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] fgraph: Fix missing unlock in register_ftrace_graph()
@ 2024-10-23 17:04 Li Huafei
2024-10-23 9:29 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: Li Huafei @ 2024-10-23 17:04 UTC (permalink / raw)
To: rostedt
Cc: dan.carpenter, mhiramat, linux-kernel, linux-trace-kernel,
oe-kbuild, lkp, lihuafei1
Instead of returning an error, goto the mutex unlock at the end of the
function.
Fixes smatch warning:
kernel/trace/fgraph.c:1317 register_ftrace_graph() warn: inconsistent returns '&ftrace_lock'.
Fixes: 2c02f7375e65 ("fgraph: Use CPU hotplug mechanism to initialize idle shadow stacks")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202410220121.wxg0olfd-lkp@intel.com/
Signed-off-by: Li Huafei <lihuafei1@huawei.com>
---
kernel/trace/fgraph.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 41e7a15dcb50..98fa7b2a4903 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1259,7 +1259,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
fgraph_cpu_init, NULL);
if (ret < 0) {
pr_warn("fgraph: Error to init cpu hotplug support\n");
- return ret;
+ goto out;
}
fgraph_initialized = true;
ret = 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] fgraph: Fix missing unlock in register_ftrace_graph()
2024-10-23 9:29 ` Steven Rostedt
@ 2024-10-24 2:45 ` Li Huafei
2024-10-24 4:46 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: Li Huafei @ 2024-10-24 2:45 UTC (permalink / raw)
To: Steven Rostedt
Cc: dan.carpenter, mhiramat, linux-kernel, linux-trace-kernel,
oe-kbuild, lkp
Hi Steve,
On 2024/10/23 17:29, Steven Rostedt wrote:
> On Thu, 24 Oct 2024 01:04:48 +0800
> Li Huafei <lihuafei1@huawei.com> wrote:
>
>> Instead of returning an error, goto the mutex unlock at the end of the
>> function.
>>
>> Fixes smatch warning:
>>
>> kernel/trace/fgraph.c:1317 register_ftrace_graph() warn: inconsistent returns '&ftrace_lock'.
>>
>> Fixes: 2c02f7375e65 ("fgraph: Use CPU hotplug mechanism to initialize idle shadow stacks")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
>> Closes: https://lore.kernel.org/r/202410220121.wxg0olfd-lkp@intel.com/
>> Signed-off-by: Li Huafei <lihuafei1@huawei.com>
>> ---
>> kernel/trace/fgraph.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
>> index 41e7a15dcb50..98fa7b2a4903 100644
>> --- a/kernel/trace/fgraph.c
>> +++ b/kernel/trace/fgraph.c
>> @@ -1259,7 +1259,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
>> fgraph_cpu_init, NULL);
>> if (ret < 0) {
>> pr_warn("fgraph: Error to init cpu hotplug support\n");
>> - return ret;
>> + goto out;
>> }
>> fgraph_initialized = true;
>> ret = 0;
>
> Actually, I'm thinking we just should use guard(mutex)(&ftrace_lock);
>
Agreed, this will make the code simpler and avoid mistakes. If we need
to replace all mutex(&ftrace_lock), would it be better to submit another
cleanup patch? We can fix the issue here first.
Thanks,
Huafei
> -- Steve
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fgraph: Fix missing unlock in register_ftrace_graph()
2024-10-24 2:45 ` Li Huafei
@ 2024-10-24 4:46 ` Steven Rostedt
2024-10-24 8:03 ` Li Huafei
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2024-10-24 4:46 UTC (permalink / raw)
To: Li Huafei
Cc: dan.carpenter, mhiramat, linux-kernel, linux-trace-kernel,
oe-kbuild, lkp
On Thu, 24 Oct 2024 10:45:46 +0800
Li Huafei <lihuafei1@huawei.com> wrote:
> Agreed, this will make the code simpler and avoid mistakes. If we need
> to replace all mutex(&ftrace_lock), would it be better to submit another
> cleanup patch? We can fix the issue here first.
This case is a bug fix, just add it here.
We can do a clean up separately for the other locations.
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fgraph: Fix missing unlock in register_ftrace_graph()
2024-10-24 4:46 ` Steven Rostedt
@ 2024-10-24 8:03 ` Li Huafei
0 siblings, 0 replies; 5+ messages in thread
From: Li Huafei @ 2024-10-24 8:03 UTC (permalink / raw)
To: Steven Rostedt
Cc: dan.carpenter, mhiramat, linux-kernel, linux-trace-kernel,
oe-kbuild, lkp
On 2024/10/24 12:46, Steven Rostedt wrote:
> On Thu, 24 Oct 2024 10:45:46 +0800
> Li Huafei <lihuafei1@huawei.com> wrote:
>
>> Agreed, this will make the code simpler and avoid mistakes. If we need
>> to replace all mutex(&ftrace_lock), would it be better to submit another
>> cleanup patch? We can fix the issue here first.
>
> This case is a bug fix, just add it here.
>
> We can do a clean up separately for the other locations.
>
Okay, I've already sent v2:
https://lore.kernel.org/lkml/20241024155917.1019580-1-lihuafei1@huawei.com/T/#u
Thanks,
Huafei
> -- Steve
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-24 8:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 17:04 [PATCH] fgraph: Fix missing unlock in register_ftrace_graph() Li Huafei
2024-10-23 9:29 ` Steven Rostedt
2024-10-24 2:45 ` Li Huafei
2024-10-24 4:46 ` Steven Rostedt
2024-10-24 8:03 ` Li Huafei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).