public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] char: misc: add missing #ifdef CONFIG_PROC_FS and error checking
@ 2024-07-29  7:35 zhangjiao2
  2024-07-29  9:42 ` Arnd Bergmann
  2024-07-29  9:43 ` [PATCH] char: misc: add missing #ifdef CONFIG_PROC_FS and error checking Greg KH
  0 siblings, 2 replies; 8+ messages in thread
From: zhangjiao2 @ 2024-07-29  7:35 UTC (permalink / raw)
  To: arnd; +Cc: gregkh, linux-kernel, trivial, Zhang Jiao

From: Zhang Jiao <zhangjiao2@cmss.chinamobile.com>

Add "#ifdef CONFIG_PROC_FS" to control misc proc create 
and give some error checking.

Signed-off-by: Zhang Jiao <zhangjiao2@cmss.chinamobile.com>
---
 drivers/char/misc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 541edc26ec89..0370d53f368a 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -286,9 +286,15 @@ EXPORT_SYMBOL(misc_deregister);
 static int __init misc_init(void)
 {
 	int err;
+#ifdef CONFIG_PROC_FS
 	struct proc_dir_entry *ret;
 
 	ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
+	if (!ret) {
+		pr_err("Cannot create /proc/misc\n");
+		return -ENOMEM;
+	}
+#endif
 	err = class_register(&misc_class);
 	if (err)
 		goto fail_remove;
@@ -302,8 +308,10 @@ static int __init misc_init(void)
 	pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
 	class_unregister(&misc_class);
 fail_remove:
+#ifdef CONFIG_PROC_FS
 	if (ret)
 		remove_proc_entry("misc", NULL);
+#endif
 	return err;
 }
 subsys_initcall(misc_init);
-- 
2.33.0




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

end of thread, other threads:[~2024-07-30 10:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-29  7:35 [PATCH] char: misc: add missing #ifdef CONFIG_PROC_FS and error checking zhangjiao2
2024-07-29  9:42 ` Arnd Bergmann
2024-07-30  8:03   ` [PATCH v2] char: misc: add missing #ifdef CONFIG_PROC_FS zhangjiao2
2024-07-30  8:42     ` Greg KH
2024-07-30  8:31       ` zhangjiao2
2024-07-30  9:11         ` Greg KH
2024-07-30 10:25           ` Arnd Bergmann
2024-07-29  9:43 ` [PATCH] char: misc: add missing #ifdef CONFIG_PROC_FS and error checking Greg KH

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