[PATCH 2/4] ksmbd: reset the server directly on startup failure
From: Huiwen He
Date: Mon Nov 30 2026 - 22:28:29 EST
From: Huiwen He <hehuiwen@xxxxxxxxxx>
If transport initialization fails, ksmbd queues another control work
item to reset the server. If allocating that item fails, the server
never schedules the reset.
Return the initialization error to the control worker and run the
reset there while it still holds ctrl_lock.
Fixes: 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Signed-off-by: Huiwen He <hehuiwen@xxxxxxxxxx>
---
fs/smb/server/server.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index 32a2201284f3..af3d2a81157a 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -596,19 +596,18 @@ static int server_conf_init(void)
return 0;
}
-static void server_ctrl_handle_init(struct server_ctrl_struct *ctrl)
+static int server_ctrl_handle_init(void)
{
int ret;
ksmbd_proc_reset();
ret = ksmbd_conn_transport_init();
- if (ret) {
- server_queue_ctrl_reset_work();
- return;
- }
+ if (ret)
+ return ret;
pr_info("running\n");
WRITE_ONCE(server_conf.state, SERVER_STATE_RUNNING);
+ return 0;
}
static void server_ctrl_handle_reset(struct server_ctrl_struct *ctrl)
@@ -630,7 +629,8 @@ static void server_ctrl_handle_work(struct work_struct *work)
mutex_lock(&ctrl_lock);
switch (ctrl->type) {
case SERVER_CTRL_TYPE_INIT:
- server_ctrl_handle_init(ctrl);
+ if (server_ctrl_handle_init())
+ server_ctrl_handle_reset(ctrl);
break;
case SERVER_CTRL_TYPE_RESET:
server_ctrl_handle_reset(ctrl);