@@ -618,39 +618,47 @@ int cifs_closedir(struct inode *inode, struct file *file)
618618 int rc = 0 ;
619619 unsigned int xid ;
620620 struct cifsFileInfo * cfile = file -> private_data ;
621- char * tmp ;
621+ struct cifs_tcon * tcon ;
622+ struct TCP_Server_Info * server ;
623+ char * buf ;
622624
623625 cFYI (1 , "Closedir inode = 0x%p" , inode );
624626
627+ if (cfile == NULL )
628+ return rc ;
629+
625630 xid = get_xid ();
631+ tcon = tlink_tcon (cfile -> tlink );
632+ server = tcon -> ses -> server ;
626633
627- if (cfile ) {
628- struct cifs_tcon * tcon = tlink_tcon (cfile -> tlink );
634+ cFYI (1 , "Freeing private data in close dir" );
635+ spin_lock (& cifs_file_list_lock );
636+ if (!cfile -> srch_inf .endOfSearch && !cfile -> invalidHandle ) {
637+ cfile -> invalidHandle = true;
638+ spin_unlock (& cifs_file_list_lock );
639+ if (server -> ops -> close_dir )
640+ rc = server -> ops -> close_dir (xid , tcon , & cfile -> fid );
641+ else
642+ rc = - ENOSYS ;
643+ cFYI (1 , "Closing uncompleted readdir with rc %d" , rc );
644+ /* not much we can do if it fails anyway, ignore rc */
645+ rc = 0 ;
646+ } else
647+ spin_unlock (& cifs_file_list_lock );
629648
630- cFYI (1 , "Freeing private data in close dir" );
631- spin_lock (& cifs_file_list_lock );
632- if (!cfile -> srch_inf .endOfSearch && !cfile -> invalidHandle ) {
633- cfile -> invalidHandle = true;
634- spin_unlock (& cifs_file_list_lock );
635- rc = CIFSFindClose (xid , tcon , cfile -> fid .netfid );
636- cFYI (1 , "Closing uncompleted readdir with rc %d" , rc );
637- /* not much we can do if it fails anyway, ignore rc */
638- rc = 0 ;
639- } else
640- spin_unlock (& cifs_file_list_lock );
641- tmp = cfile -> srch_inf .ntwrk_buf_start ;
642- if (tmp ) {
643- cFYI (1 , "closedir free smb buf in srch struct" );
644- cfile -> srch_inf .ntwrk_buf_start = NULL ;
645- if (cfile -> srch_inf .smallBuf )
646- cifs_small_buf_release (tmp );
647- else
648- cifs_buf_release (tmp );
649- }
650- cifs_put_tlink (cfile -> tlink );
651- kfree (file -> private_data );
652- file -> private_data = NULL ;
649+ buf = cfile -> srch_inf .ntwrk_buf_start ;
650+ if (buf ) {
651+ cFYI (1 , "closedir free smb buf in srch struct" );
652+ cfile -> srch_inf .ntwrk_buf_start = NULL ;
653+ if (cfile -> srch_inf .smallBuf )
654+ cifs_small_buf_release (buf );
655+ else
656+ cifs_buf_release (buf );
653657 }
658+
659+ cifs_put_tlink (cfile -> tlink );
660+ kfree (file -> private_data );
661+ file -> private_data = NULL ;
654662 /* BB can we lock the filestruct while this is going on? */
655663 free_xid (xid );
656664 return rc ;
0 commit comments