Skip to content

Commit d304c91

Browse files
Ronnie Sahlberggregkh
authored andcommitted
cifs: check MaxPathNameComponentLength != 0 before using it
commit f74bc7c6679200a4a83156bb89cbf6c229fe8ec0 upstream. And fix tcon leak in error path. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8142e95 commit d304c91

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
@@ -193,7 +193,8 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)
193193
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
194194
int i;
195195

196-
if (unlikely(direntry->d_name.len >
196+
if (unlikely(tcon->fsAttrInfo.MaxPathNameComponentLength &&
197+
direntry->d_name.len >
197198
le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
198199
return -ENAMETOOLONG;
199200

@@ -509,7 +510,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
509510

510511
rc = check_name(direntry, tcon);
511512
if (rc)
512-
goto out_free_xid;
513+
goto out;
513514

514515
server = tcon->ses->server;
515516

0 commit comments

Comments
 (0)