From: Shachar Sharon Date: Wed, 3 Dec 2025 09:39:51 +0000 (+0200) Subject: vfs_ceph_new: proper failure-handling in chdir and getwd X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32cd874892d0fb4dded3282ce5a723e0cbb0f2df;p=thirdparty%2Fsamba.git vfs_ceph_new: proper failure-handling in chdir and getwd In case of an unlikely failure of SMB_VFS_HANDLE_GET_DATA macro, bail out using 'goto' in order to ensure that START_PROFILE_X is properly matched by END_PROFILE_X. Signed-off-by: Shachar Sharon Reviewed-by: John Mulligan Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Thu Dec 4 10:02:55 UTC 2025 on atb-devel-224 --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index d0f35affac7..1ef3ca3714a 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -3408,16 +3408,18 @@ out: static int vfs_ceph_chdir(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { - int result = -1; + int result = -ENOMEM; struct vfs_ceph_config *config = NULL; START_PROFILE_X(SNUM(handle->conn), syscall_chdir); + SMB_VFS_HANDLE_GET_DATA(handle, config, struct vfs_ceph_config, - return -ENOMEM); + goto out); DBG_DEBUG("[CEPH] chdir: handle=%p name=%s\n", handle, smb_fname->base_name); result = config->ceph_chdir_fn(config->mount, smb_fname->base_name); DBG_DEBUG("[CEPH] chdir: name=%s result=%d\n", smb_fname->base_name, result); +out: END_PROFILE_X(syscall_chdir); return status_code(result); } @@ -3427,15 +3429,18 @@ static struct smb_filename *vfs_ceph_getwd(struct vfs_handle_struct *handle, { const char *cwd = NULL; struct vfs_ceph_config *config = NULL; + struct smb_filename *result = NULL; START_PROFILE_X(SNUM(handle->conn), syscall_getwd); SMB_VFS_HANDLE_GET_DATA(handle, config, struct vfs_ceph_config, - return NULL); + goto out); cwd = config->ceph_getcwd_fn(config->mount); DBG_DEBUG("[CEPH] getwd: handle=%p cwd=%s\n", handle, cwd); + result = cp_smb_basename(ctx, cwd); +out: END_PROFILE_X(syscall_getwd); - return cp_smb_basename(ctx, cwd); + return result; } static int strict_allocate_ftruncate(struct vfs_handle_struct *handle,