[PATCH OLK-6.6] [Huawei] inspector: hold module refcnt when cpu inspector is running

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICO6WK ---------------------------------------------------------------------- To avoid accessing a null CPU inspector during the inspection process, the module should remain in use until the inspection is complete. Fixes: d91c6db8ca89 ("cpuinspect: add CPU-inspect infrastructure") Signed-off-by: Qi Xi <xiqi2@huawei.com> --- drivers/cpuinspect/cpuinspect.c | 6 ++++++ drivers/cpuinspect/inspector-atf.c | 1 + include/linux/cpuinspect.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/cpuinspect/cpuinspect.c b/drivers/cpuinspect/cpuinspect.c index 33eabe49866a..069c7ed5971a 100644 --- a/drivers/cpuinspect/cpuinspect.c +++ b/drivers/cpuinspect/cpuinspect.c @@ -49,6 +49,11 @@ static int run_inspector(void *data) ktime_t start_time, duration; unsigned long sleep_us; + if (!try_module_get(curr_cpu_inspector->owner)) { + pr_err("failed to get inspector module reference\n"); + return -ENOENT; + } + while (!kthread_should_stop()) { if (inspect_times >= ci_core.inspect_times || !cpu_online(cpu)) break; @@ -96,6 +101,7 @@ static int run_inspector(void *data) cpuinspect_result_notify(); } + module_put(curr_cpu_inspector->owner); return 0; } diff --git a/drivers/cpuinspect/inspector-atf.c b/drivers/cpuinspect/inspector-atf.c index 00adaff5a19a..2bb03db6e3c3 100644 --- a/drivers/cpuinspect/inspector-atf.c +++ b/drivers/cpuinspect/inspector-atf.c @@ -50,6 +50,7 @@ static int atf_run_chip_test(unsigned int group) static struct cpu_inspector atf_inspector = { .name = "atf", .start_inspect = atf_run_chip_test, + .owner = THIS_MODULE, }; /** diff --git a/include/linux/cpuinspect.h b/include/linux/cpuinspect.h index 596b7d82abb4..5c767b38cd78 100644 --- a/include/linux/cpuinspect.h +++ b/include/linux/cpuinspect.h @@ -30,6 +30,7 @@ struct cpu_inspector { const char name[CPUINSPECT_NAME_LEN]; struct list_head list; unsigned long group_num; + struct module *owner; int (*start_inspect)(unsigned int group); }; -- 2.33.0

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/17255 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/FOA... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/17255 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/FOA...
participants (2)
-
patchwork bot
-
Qi Xi