smb: client: Use more common code in open_cached_dir()
Subsystems (3)
PATCH 1/1 smb: client: Use more common code in open_cached_dir()
From: Markus Elfring <[email protected]>
Date: Tue, 7 Oct 2025 15:34:56 +0200
Use two additional labels so that another bit of common code can be better reused at the end of this function implementation.
Signed-off-by Markus Elfring <[email protected]>
--- fs/smb/client/cached_dir.c | 42 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
fs/smb/client/cached_dir.c +20 -22
@@ -184,9 +184,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,spin_lock (&cfids->cfid_list_lock); cfid =find_or_create_cached_dir (cfids, path, lookup_only, tcon->max_cached_dirs);if (cfid ==NULL ) { -spin_unlock (&cfids->cfid_list_lock); -kfree (utf16_path); -return -ENOENT ; + rc = -ENOENT ; + goto free_unlock_list; }/* * Return cached fid if it is valid (has a lease and has a time).
@@ -195,10 +194,9 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,*/ if (is_valid_cached_dir (cfid)) { cfid->last_access_time = jiffies; -spin_unlock (&cfids->cfid_list_lock); *ret_cfid = cfid; -kfree (utf16_path); -return 0 ; + rc =0 ; + goto free_unlock_list; }spin_unlock (&cfids->cfid_list_lock);
@@ -331,30 +329,25 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,if (o_rsp->OplockLevel !=SMB2_OPLOCK_LEVEL_LEASE ) { -spin_unlock (&cfids->cfid_list_lock); rc = -EINVAL ; - goto oshr_free; + goto unlock_list; } rc =smb2_parse_contexts (server, rsp_iov, &oparms.fid->epoch, oparms.fid->lease_key, &oplock,NULL ,NULL ); -if (rc) { -spin_unlock (&cfids->cfid_list_lock); - goto oshr_free; - } +if (rc) + goto unlock_list; rc = -EINVAL ; -if (!(oplock &SMB2_LEASE_READ_CACHING_HE )) { -spin_unlock (&cfids->cfid_list_lock); - goto oshr_free; - } +if (!(oplock &SMB2_LEASE_READ_CACHING_HE )) + goto unlock_list; + qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1 ].iov_base; -if (le32_to_cpu (qi_rsp->OutputBufferLength) <sizeof (struct smb2_file_all_info )) { -spin_unlock (&cfids->cfid_list_lock); - goto oshr_free; - } +if (le32_to_cpu (qi_rsp->OutputBufferLength) <sizeof (struct smb2_file_all_info )) + goto unlock_list; + if (!smb2_validate_and_copy_iov( le16_to_cpu(qi_rsp->OutputBufferOffset), sizeof(struct smb2_file_all_info),
@@ -364,10 +357,10 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, cfid->time = jiffies; cfid->last_access_time = jiffies; -spin_unlock (&cfids->cfid_list_lock);/* At this point the directory handle is fully cached */ rc =0 ; - +unlock_list: +spin_unlock (&cfids->cfid_list_lock); oshr_free:SMB2_open_free (&rqst[0 ]);SMB2_query_info_free (&rqst[1 ]);
@@ -404,6 +397,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, goto replay_again;return rc; + +free_unlock_list: +spin_unlock (&cfids->cfid_list_lock); +kfree (utf16_path); +return rc; } int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
Signature · 1 line
2.51.0