Skip to content

Commit f74bc7c

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: check MaxPathNameComponentLength != 0 before using it
And fix tcon leak in error path. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> CC: Stable <stable@vger.kernel.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
1 parent 0b07194 commit f74bc7c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/cifs/dir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)
204204
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
205205
int i;
206206

207-
if (unlikely(direntry->d_name.len >
207+
if (unlikely(tcon->fsAttrInfo.MaxPathNameComponentLength &&
208+
direntry->d_name.len >
208209
le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
209210
return -ENAMETOOLONG;
210211

@@ -520,7 +521,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
520521

521522
rc = check_name(direntry, tcon);
522523
if (rc)
523-
goto out_free_xid;
524+
goto out;
524525

525526
server = tcon->ses->server;
526527

0 commit comments

Comments
 (0)