* [PATCH] [media] saa7164: fix remove_proc_entry warning
@ 2019-05-04 7:10 Kefeng Wang
2019-05-27 8:03 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Kefeng Wang @ 2019-05-04 7:10 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, linux-kernel, Mauro Carvalho Chehab
Cc: Kefeng Wang
if saa7164_proc_create() fails, saa7164_fini() will trigger a warning,
name 'saa7164'
WARNING: CPU: 1 PID: 6311 at fs/proc/generic.c:672 remove_proc_entry+0x1e8/0x3a0
? remove_proc_entry+0x1e8/0x3a0
? try_stop_module+0x7b/0x240
? proc_readdir+0x70/0x70
? rcu_read_lock_sched_held+0xd7/0x100
saa7164_fini+0x13/0x1f [saa7164]
__x64_sys_delete_module+0x30c/0x480
? __ia32_sys_delete_module+0x480/0x480
? __x64_sys_clock_gettime+0x11e/0x1c0
? __x64_sys_timer_create+0x1a0/0x1a0
? trace_hardirqs_off_caller+0x40/0x180
? do_syscall_64+0x18/0x450
do_syscall_64+0x9f/0x450
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fix it by checking the return of proc_create_single() before
calling remove_proc_entry().
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
drivers/media/pci/saa7164/saa7164-core.c | 31 +++++++++++++++---------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 05f25c9bb308..51dff0d84399 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1122,16 +1122,23 @@ static int saa7164_proc_show(struct seq_file *m, void *v)
return 0;
}
+static struct proc_dir_entry *saa7164_pe;
static int saa7164_proc_create(void)
{
- struct proc_dir_entry *pe;
-
- pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
- if (!pe)
+ saa7164_pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
+ if (!saa7164_pe)
return -ENOMEM;
return 0;
}
+static void saa7164_proc_destory(void)
+{
+ if (saa7164_pe)
+ remove_proc_entry("saa7164", NULL);
+}
+#else
+static int saa7164_proc_create(void) { return 0; }
+static void saa7164_proc_destory(void) {}
#endif
static int saa7164_thread_function(void *data)
@@ -1503,19 +1510,21 @@ static struct pci_driver saa7164_pci_driver = {
static int __init saa7164_init(void)
{
- printk(KERN_INFO "saa7164 driver loaded\n");
+ int ret = pci_register_driver(&saa7164_pci_driver);
+
+ if (ret)
+ return ret;
-#ifdef CONFIG_PROC_FS
saa7164_proc_create();
-#endif
- return pci_register_driver(&saa7164_pci_driver);
+
+ printk(KERN_INFO "saa7164 driver loaded\n");
+
+ return 0;
}
static void __exit saa7164_fini(void)
{
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("saa7164", NULL);
-#endif
+ saa7164_proc_destory();
pci_unregister_driver(&saa7164_pci_driver);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] saa7164: fix remove_proc_entry warning
2019-05-04 7:10 [PATCH] [media] saa7164: fix remove_proc_entry warning Kefeng Wang
@ 2019-05-27 8:03 ` Hans Verkuil
2019-05-27 12:14 ` [PATCH v2] media: " Kefeng Wang
0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2019-05-27 8:03 UTC (permalink / raw)
To: Kefeng Wang, Mauro Carvalho Chehab, linux-media, linux-kernel,
Mauro Carvalho Chehab
On 5/4/19 9:10 AM, Kefeng Wang wrote:
> if saa7164_proc_create() fails, saa7164_fini() will trigger a warning,
>
> name 'saa7164'
> WARNING: CPU: 1 PID: 6311 at fs/proc/generic.c:672 remove_proc_entry+0x1e8/0x3a0
> ? remove_proc_entry+0x1e8/0x3a0
> ? try_stop_module+0x7b/0x240
> ? proc_readdir+0x70/0x70
> ? rcu_read_lock_sched_held+0xd7/0x100
> saa7164_fini+0x13/0x1f [saa7164]
> __x64_sys_delete_module+0x30c/0x480
> ? __ia32_sys_delete_module+0x480/0x480
> ? __x64_sys_clock_gettime+0x11e/0x1c0
> ? __x64_sys_timer_create+0x1a0/0x1a0
> ? trace_hardirqs_off_caller+0x40/0x180
> ? do_syscall_64+0x18/0x450
> do_syscall_64+0x9f/0x450
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Fix it by checking the return of proc_create_single() before
> calling remove_proc_entry().
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> drivers/media/pci/saa7164/saa7164-core.c | 31 +++++++++++++++---------
> 1 file changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
> index 05f25c9bb308..51dff0d84399 100644
> --- a/drivers/media/pci/saa7164/saa7164-core.c
> +++ b/drivers/media/pci/saa7164/saa7164-core.c
> @@ -1122,16 +1122,23 @@ static int saa7164_proc_show(struct seq_file *m, void *v)
> return 0;
> }
>
> +static struct proc_dir_entry *saa7164_pe;
Add empty line to separate this global from the function.
> static int saa7164_proc_create(void)
> {
> - struct proc_dir_entry *pe;
> -
> - pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
> - if (!pe)
> + saa7164_pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
> + if (!saa7164_pe)
> return -ENOMEM;
>
> return 0;
> }
Add empty line to separate the two functions.
> +static void saa7164_proc_destory(void)
destory -> destroy
> +{
> + if (saa7164_pe)
> + remove_proc_entry("saa7164", NULL);
> +}
> +#else
> +static int saa7164_proc_create(void) { return 0; }
> +static void saa7164_proc_destory(void) {}
> #endif
>
> static int saa7164_thread_function(void *data)
> @@ -1503,19 +1510,21 @@ static struct pci_driver saa7164_pci_driver = {
>
> static int __init saa7164_init(void)
> {
> - printk(KERN_INFO "saa7164 driver loaded\n");
> + int ret = pci_register_driver(&saa7164_pci_driver);
> +
> + if (ret)
> + return ret;
>
> -#ifdef CONFIG_PROC_FS
> saa7164_proc_create();
> -#endif
> - return pci_register_driver(&saa7164_pci_driver);
> +
> + printk(KERN_INFO "saa7164 driver loaded\n");
> +
> + return 0;
> }
>
> static void __exit saa7164_fini(void)
> {
> -#ifdef CONFIG_PROC_FS
> - remove_proc_entry("saa7164", NULL);
> -#endif
> + saa7164_proc_destory();
> pci_unregister_driver(&saa7164_pci_driver);
> }
>
>
Regards,
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] media: saa7164: fix remove_proc_entry warning
2019-05-27 8:03 ` Hans Verkuil
@ 2019-05-27 12:14 ` Kefeng Wang
0 siblings, 0 replies; 3+ messages in thread
From: Kefeng Wang @ 2019-05-27 12:14 UTC (permalink / raw)
To: linux-media, linux-kernel
Cc: Kefeng Wang, Hans Verkuil, Mauro Carvalho Chehab, Mauro Carvalho Chehab
if saa7164_proc_create() fails, saa7164_fini() will trigger a warning,
name 'saa7164'
WARNING: CPU: 1 PID: 6311 at fs/proc/generic.c:672 remove_proc_entry+0x1e8/0x3a0
? remove_proc_entry+0x1e8/0x3a0
? try_stop_module+0x7b/0x240
? proc_readdir+0x70/0x70
? rcu_read_lock_sched_held+0xd7/0x100
saa7164_fini+0x13/0x1f [saa7164]
__x64_sys_delete_module+0x30c/0x480
? __ia32_sys_delete_module+0x480/0x480
? __x64_sys_clock_gettime+0x11e/0x1c0
? __x64_sys_timer_create+0x1a0/0x1a0
? trace_hardirqs_off_caller+0x40/0x180
? do_syscall_64+0x18/0x450
do_syscall_64+0x9f/0x450
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fix it by checking the return of proc_create_single() before
calling remove_proc_entry().
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
drivers/media/pci/saa7164/saa7164-core.c | 33 ++++++++++++++++--------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 05f25c9bb308..04d566b1b41e 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1122,16 +1122,25 @@ static int saa7164_proc_show(struct seq_file *m, void *v)
return 0;
}
+static struct proc_dir_entry *saa7164_pe;
+
static int saa7164_proc_create(void)
{
- struct proc_dir_entry *pe;
-
- pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
- if (!pe)
+ saa7164_pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show);
+ if (!saa7164_pe)
return -ENOMEM;
return 0;
}
+
+static void saa7164_proc_destroy(void)
+{
+ if (saa7164_pe)
+ remove_proc_entry("saa7164", NULL);
+}
+#else
+static int saa7164_proc_create(void) { return 0; }
+static void saa7164_proc_destroy(void) {}
#endif
static int saa7164_thread_function(void *data)
@@ -1503,19 +1512,21 @@ static struct pci_driver saa7164_pci_driver = {
static int __init saa7164_init(void)
{
- printk(KERN_INFO "saa7164 driver loaded\n");
+ int ret = pci_register_driver(&saa7164_pci_driver);
+
+ if (ret)
+ return ret;
-#ifdef CONFIG_PROC_FS
saa7164_proc_create();
-#endif
- return pci_register_driver(&saa7164_pci_driver);
+
+ printk(KERN_INFO "saa7164 driver loaded\n");
+
+ return 0;
}
static void __exit saa7164_fini(void)
{
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("saa7164", NULL);
-#endif
+ saa7164_proc_destroy();
pci_unregister_driver(&saa7164_pci_driver);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-27 12:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-04 7:10 [PATCH] [media] saa7164: fix remove_proc_entry warning Kefeng Wang
2019-05-27 8:03 ` Hans Verkuil
2019-05-27 12:14 ` [PATCH v2] media: " Kefeng Wang
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).