Skip to content

Commit 61da08e

Browse files
elfringsmfrench
authored andcommitted
smb: client: Use common code in cifs_lookup()
Use three 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 <elfring@users.sourceforge.net> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent e7933f5 commit 61da08e

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

fs/smb/client/dir.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
678678
const char *full_path;
679679
void *page;
680680
int retry_count = 0;
681+
struct dentry *de;
681682

682683
xid = get_xid();
683684

@@ -689,16 +690,15 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
689690
cifs_sb = CIFS_SB(parent_dir_inode->i_sb);
690691
tlink = cifs_sb_tlink(cifs_sb);
691692
if (IS_ERR(tlink)) {
692-
free_xid(xid);
693-
return ERR_CAST(tlink);
693+
de = ERR_CAST(tlink);
694+
goto free_xid;
694695
}
695696
pTcon = tlink_tcon(tlink);
696697

697698
rc = check_name(direntry, pTcon);
698699
if (unlikely(rc)) {
699-
cifs_put_tlink(tlink);
700-
free_xid(xid);
701-
return ERR_PTR(rc);
700+
de = ERR_PTR(rc);
701+
goto put_tlink;
702702
}
703703

704704
/* can not grab the rename sem here since it would
@@ -707,10 +707,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
707707
page = alloc_dentry_path();
708708
full_path = build_path_from_dentry(direntry, page);
709709
if (IS_ERR(full_path)) {
710-
cifs_put_tlink(tlink);
711-
free_xid(xid);
712-
free_dentry_path(page);
713-
return ERR_CAST(full_path);
710+
de = ERR_CAST(full_path);
711+
goto free_dentry_path;
714712
}
715713

716714
if (d_really_is_positive(direntry)) {
@@ -776,10 +774,14 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
776774
}
777775

778776
out:
777+
de = d_splice_alias(newInode, direntry);
778+
free_dentry_path:
779779
free_dentry_path(page);
780+
put_tlink:
780781
cifs_put_tlink(tlink);
782+
free_xid:
781783
free_xid(xid);
782-
return d_splice_alias(newInode, direntry);
784+
return de;
783785
}
784786

785787
static int

0 commit comments

Comments
 (0)