From: Volker Lendecke Date: Fri, 17 Oct 2025 12:10:49 +0000 (+0200) Subject: smbd: Remove the one-line conn_free() wrapper function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d5bf396855d66dba718ad96e64c4d4d6fc7e615;p=thirdparty%2Fsamba.git smbd: Remove the one-line conn_free() wrapper function In case there's more things to do here we should put it into the destructor. Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c index 2f75e2dc61b..8704623a30f 100644 --- a/source3/rpc_server/mdssvc/mdssvc.c +++ b/source3/rpc_server/mdssvc/mdssvc.c @@ -1622,7 +1622,7 @@ static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx) if (mds_ctx->conn != NULL) { SMB_VFS_DISCONNECT(mds_ctx->conn); - conn_free(mds_ctx->conn); + TALLOC_FREE(mds_ctx->conn); } ZERO_STRUCTP(mds_ctx); diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index f1c75e29205..f4169b36eb1 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -131,10 +131,6 @@ connection_struct *conn_new(struct smbd_server_connection *sconn) DLIST_ADD(sconn->connections, conn); sconn->num_connections++; - /* - * Catches the case where someone forgets to call - * conn_free(). - */ talloc_set_destructor(conn, conn_struct_destructor); return conn; @@ -241,15 +237,6 @@ static void conn_free_internal(connection_struct *conn) ZERO_STRUCTP(conn); } -/**************************************************************************** - Free a conn structure. -****************************************************************************/ - -void conn_free(connection_struct *conn) -{ - TALLOC_FREE(conn); -} - /* * Correctly initialize a share with case options. */ diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 57617252643..e09c2a83a61 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -272,7 +272,7 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx, "denied due to security " "descriptor.\n", servicename); - conn_free(conn); + TALLOC_FREE(conn); return NT_STATUS_ACCESS_DENIED; } conn->read_only = true; @@ -281,21 +281,21 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx, if (!smbd_vfs_init(conn)) { NTSTATUS status = map_nt_error_from_unix(errno); DBG_ERR("smbd_vfs_init failed.\n"); - conn_free(conn); + TALLOC_FREE(conn); return status; } /* this must be the first filesystem operation that we do */ if (SMB_VFS_CONNECT(conn, servicename, vfs_user) < 0) { DBG_ERR("VFS connect failed!\n"); - conn_free(conn); + TALLOC_FREE(conn); return NT_STATUS_UNSUCCESSFUL; } ok = canonicalize_connect_path(conn); if (!ok) { DBG_ERR("Failed to canonicalize sharepath\n"); - conn_free(conn); + TALLOC_FREE(conn); return NT_STATUS_ACCESS_DENIED; } @@ -313,7 +313,7 @@ static int conn_struct_tos_destructor(struct conn_struct_tos *c) TALLOC_FREE(c->oldcwd_fname); } SMB_VFS_DISCONNECT(c->conn); - conn_free(c->conn); + TALLOC_FREE(c->conn); return 0; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 2c71a246aeb..7e34cd4443e 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -157,7 +157,6 @@ bool conn_using_smb2(struct smbd_server_connection *sconn); connection_struct *conn_new(struct smbd_server_connection *sconn); bool conn_idle_all(struct smbd_server_connection *sconn, time_t t); void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint64_t vuid); -void conn_free(connection_struct *conn); void conn_setup_case_options(connection_struct *conn); void conn_force_tdis( struct smbd_server_connection *sconn, diff --git a/source3/smbd/smb1_service.c b/source3/smbd/smb1_service.c index 99541010c40..fc4fa11b75a 100644 --- a/source3/smbd/smb1_service.c +++ b/source3/smbd/smb1_service.c @@ -104,7 +104,7 @@ static connection_struct *make_connection_smb1(struct smb_request *req, req->session, pdev); if (!NT_STATUS_IS_OK(*pstatus)) { - conn_free(conn); + TALLOC_FREE(conn); TALLOC_FREE(tcon); return NULL; } diff --git a/source3/smbd/smb2_service.c b/source3/smbd/smb2_service.c index e43c3d9faa2..9f4035efce3 100644 --- a/source3/smbd/smb2_service.c +++ b/source3/smbd/smb2_service.c @@ -899,7 +899,7 @@ connection_struct *make_connection_smb2(struct smbd_smb2_request *req, req->session, pdev); if (!NT_STATUS_IS_OK(*pstatus)) { - conn_free(conn); + TALLOC_FREE(conn); return NULL; } return conn; @@ -970,5 +970,5 @@ void close_cnum(connection_struct *conn, TALLOC_FREE(cmd); } - conn_free(conn); + TALLOC_FREE(conn); }