From: ZhangGuoDong <zhang.guodong@linux.dev>
To: smfrench@gmail.com, linkinjeon@kernel.org, pc@manguebit.org,
ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
bharathsm@microsoft.com, senozhatsky@chromium.org,
dhowells@redhat.com, metze@samba.org
Cc: linux-cifs@vger.kernel.org,
ZhangGuoDong <zhangguodong@kylinos.cn>,
ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 5/6] smb/server: call ksmbd_proc_cleanup() on module init failure
Date: Fri, 31 Jul 2026 11:50:07 +0000 [thread overview]
Message-ID: <20260731115008.111211-6-zhang.guodong@linux.dev> (raw)
In-Reply-To: <20260731115008.111211-1-zhang.guodong@linux.dev>
From: ZhangGuoDong <zhangguodong@kylinos.cn>
When a later initializer fails, the unwind chain releases resources
created after procfs and then jumps directly to class_unregister().
Returning an error from module_init() leaves the proc tree and its
per-CPU counters allocated.
Fixes: b38f99c1217a ("ksmbd: add procfs interface for runtime monitoring and statistics")
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/server.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index 19630ac53235..0ccd123ba418 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -630,11 +630,11 @@ static int __init ksmbd_server_init(void)
ret = server_conf_init();
if (ret)
- goto err_unregister;
+ goto err_proc_cleanup;
ret = ksmbd_work_pool_init();
if (ret)
- goto err_unregister;
+ goto err_proc_cleanup;
ret = ksmbd_init_file_cache();
if (ret)
@@ -680,6 +680,8 @@ static int __init ksmbd_server_init(void)
ksmbd_exit_file_cache();
err_destroy_work_pools:
ksmbd_work_pool_destroy();
+err_proc_cleanup:
+ ksmbd_proc_cleanup();
err_unregister:
class_unregister(&ksmbd_control_class);
--
2.54.0
next prev parent reply other threads:[~2026-07-31 11:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 11:50 [PATCH 0/6] ksmbd: fix some bugs ZhangGuoDong
2026-07-31 11:50 ` [PATCH 1/6] smb/server: fix null-ptr-deref in ksmbd_ipc_tree_connect_request() ZhangGuoDong
2026-07-31 11:50 ` [PATCH 2/6] smb/server: fix memory leak in ksmbd_vfs_set_durable_owner() ZhangGuoDong
2026-07-31 11:50 ` [PATCH 3/6] smb/server: fix invalid pointer dereference in ksmbd_stop_durable_scavenger() ZhangGuoDong
2026-07-31 11:50 ` [PATCH 4/6] smb/server: abort initialization when proc setup fails ZhangGuoDong
2026-07-31 11:50 ` ZhangGuoDong [this message]
2026-07-31 11:50 ` [PATCH 6/6] smb/server: preserve error status in smb2_handle_negotiate() ZhangGuoDong
2026-08-01 2:10 ` [PATCH 0/6] ksmbd: fix some bugs Namjae Jeon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731115008.111211-6-zhang.guodong@linux.dev \
--to=zhang.guodong@linux.dev \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong@kylinos.cn \
--cc=dhowells@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=metze@samba.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=zhangguodong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox