From: Ralph Boehme Date: Tue, 2 Feb 2021 12:49:56 +0000 (+0100) Subject: smbd: simplify error codepath in openat_pathref_fsp() X-Git-Tag: tevent-0.11.0~1821 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd3d970c84b340630745bc555a86ac2d1306baac;p=thirdparty%2Fsamba.git smbd: simplify error codepath in openat_pathref_fsp() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 8d7ecabe285..e3e02e5dad1 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -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)) {