提交 4edf7a38 编写于 作者: A Armin Wolf 提交者: Zheng Zengkai

hwmon: (dell-smm) Fix warning on /proc/i8k creation error

stable inclusion
from stable-v5.10.87
commit 6992d8c215c872c208b895fba1e13e07c8c94a83
bugzilla: 186049 https://gitee.com/openeuler/kernel/issues/I4QVYL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6992d8c215c872c208b895fba1e13e07c8c94a83

--------------------------------

commit dbd3e6ea upstream.

The removal function is called regardless of whether
/proc/i8k was created successfully or not, the later
causing a WARN() on module removal.
Fix that by only registering the removal function
if /proc/i8k was created successfully.

Tested on a Inspiron 3505.

Fixes: 039ae585 ("hwmon: Allow to compile dell-smm-hwmon driver without /proc/i8k")
Signed-off-by: NArmin Wolf <W_Armin@gmx.de>
Acked-by: NPali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211112171440.59006-1-W_Armin@gmx.deSigned-off-by: NGuenter Roeck <linux@roeck-us.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 f562783e
......@@ -603,15 +603,18 @@ static const struct proc_ops i8k_proc_ops = {
.proc_ioctl = i8k_ioctl,
};
static struct proc_dir_entry *entry;
static void __init i8k_init_procfs(void)
{
/* Register the proc entry */
proc_create("i8k", 0, NULL, &i8k_proc_ops);
entry = proc_create("i8k", 0, NULL, &i8k_proc_ops);
}
static void __exit i8k_exit_procfs(void)
{
remove_proc_entry("i8k", NULL);
if (entry)
remove_proc_entry("i8k", NULL);
}
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册