smbd: simplify error codepath in openat_pathref_fsp()
authorRalph Boehme <slow@samba.org>
Tue, 2 Feb 2021 12:49:56 +0000 (13:49 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 5 Feb 2021 06:22:35 +0000 (06:22 +0000)
No change in behaviour: the cleanup code at the fail label does the same as the
cleanup this patch removes. It has an extra fd_close() that is not existing in
the removed cleanup, but as fsp->fd is -1, that's a noop.

And when previously the

return NT_STATUS_OBJECT_NAME_NOT_FOUND;

returns an an explicit status code, when now doing goto fail status will also be
set to NT_STATUS_OBJECT_NAME_NOT_FOUND.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/files.c

index 8d7ecabe2851e5b2d8c70b378129fbb15c5d52a2..e3e02e5dad1cf965978c9237b0114ab3b1c5e674 100644 (file)
@@ -502,21 +502,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 
        status = fd_openat(dirfsp, smb_fname, fsp, open_flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
-               DBG_DEBUG("Could not open fd for [%s]: %s\n",
-                         fsp_str_dbg(fsp),
-                         nt_errstr(status));
-
-               if (fsp->base_fsp != NULL) {
-                       struct files_struct *tmp_base_fsp = fsp->base_fsp;
-
-                       fsp_set_base_fsp(fsp, NULL);
-
-                       fd_close(tmp_base_fsp);
-                       file_free(NULL, tmp_base_fsp);
-               }
-               file_free(NULL, fsp);
-               fsp = NULL;
-
                if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) ||
                    NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND))
                {
@@ -533,11 +518,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                         */
                        status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
                }
-               if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
-                       goto fail;
-               }
-
-               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+               goto fail;
        }
 
        if (!check_same_dev_ino(&smb_fname->st, &fsp->fsp_name->st)) {