]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Save lines in conn_new()
authorVolker Lendecke <vl@samba.org>
Mon, 20 Oct 2025 14:35:09 +0000 (16:35 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 10 Nov 2025 13:29:30 +0000 (13:29 +0000)
"nomem" is the only failure condition here

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/conn.c

index bcd509d786497822e23d729795a1b3fef829f23f..40a9fc482e15ab0875be0a74b1339ecdd7683677 100644 (file)
@@ -96,32 +96,23 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
 
        conn = talloc_zero(NULL, connection_struct);
        if (conn == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               return NULL;
+               goto nomem;
        }
        conn->params = talloc(conn, struct share_params);
        if (conn->params == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->vuid_cache = talloc_zero(conn, struct vuid_cache);
        if (conn->vuid_cache == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->connectpath = talloc_strdup(conn, "");
        if (conn->connectpath == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->cwd_fsp = talloc_zero(conn, struct files_struct);
        if (conn->cwd_fsp == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->cwd_fsp->fsp_name = synthetic_smb_fname(conn->cwd_fsp,
                                                      ".",
@@ -130,14 +121,11 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
                                                      0,
                                                      0);
        if (conn->cwd_fsp->fsp_name == NULL) {
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->cwd_fsp->fh = fd_handle_create(conn->cwd_fsp);
        if (conn->cwd_fsp->fh == NULL) {
-               DBG_ERR("talloc_zero failed\n");
-               TALLOC_FREE(conn);
-               return NULL;
+               goto nomem;
        }
        conn->sconn = sconn;
        conn->force_group_gid = (gid_t)-1;
@@ -154,6 +142,11 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
         */
        talloc_set_destructor(conn, conn_struct_destructor);
        return conn;
+
+nomem:
+       DBG_ERR("talloc failed");
+       TALLOC_FREE(conn);
+       return NULL;
 }
 
 /****************************************************************************