@@ -33,10 +33,9 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
33
33
struct exfat_chain * p_dir , int entry , unsigned short * uniname )
34
34
{
35
35
int i ;
36
- struct exfat_entry_set_cache * es ;
36
+ struct exfat_entry_set_cache es ;
37
37
38
- es = exfat_get_dentry_set (sb , p_dir , entry , ES_ALL_ENTRIES );
39
- if (!es )
38
+ if (exfat_get_dentry_set (& es , sb , p_dir , entry , ES_ALL_ENTRIES ))
40
39
return ;
41
40
42
41
/*
@@ -45,8 +44,8 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
45
44
* Third entry : first file-name entry
46
45
* So, the index of first file-name dentry should start from 2.
47
46
*/
48
- for (i = 2 ; i < es -> num_entries ; i ++ ) {
49
- struct exfat_dentry * ep = exfat_get_dentry_cached (es , i );
47
+ for (i = 2 ; i < es . num_entries ; i ++ ) {
48
+ struct exfat_dentry * ep = exfat_get_dentry_cached (& es , i );
50
49
51
50
/* end of name entry */
52
51
if (exfat_get_entry_type (ep ) != TYPE_EXTEND )
@@ -56,7 +55,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
56
55
uniname += EXFAT_FILE_NAME_LEN ;
57
56
}
58
57
59
- exfat_free_dentry_set (es , false);
58
+ exfat_free_dentry_set (& es , false);
60
59
}
61
60
62
61
/* read a directory entry from the opened directory */
@@ -619,7 +618,6 @@ int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
619
618
if (IS_DYNAMIC_ES (es ))
620
619
kfree (es -> bh );
621
620
622
- kfree (es );
623
621
return err ;
624
622
}
625
623
@@ -816,32 +814,30 @@ struct exfat_dentry *exfat_get_dentry_cached(
816
814
* pointer of entry set on success,
817
815
* NULL on failure.
818
816
*/
819
- struct exfat_entry_set_cache * exfat_get_dentry_set (struct super_block * sb ,
820
- struct exfat_chain * p_dir , int entry , unsigned int type )
817
+ int exfat_get_dentry_set (struct exfat_entry_set_cache * es ,
818
+ struct super_block * sb , struct exfat_chain * p_dir , int entry ,
819
+ unsigned int type )
821
820
{
822
821
int ret , i , num_bh ;
823
822
unsigned int off , byte_offset , clu = 0 ;
824
823
sector_t sec ;
825
824
struct exfat_sb_info * sbi = EXFAT_SB (sb );
826
- struct exfat_entry_set_cache * es ;
827
825
struct exfat_dentry * ep ;
828
826
int num_entries ;
829
827
enum exfat_validate_dentry_mode mode = ES_MODE_STARTED ;
830
828
struct buffer_head * bh ;
831
829
832
830
if (p_dir -> dir == DIR_DELETED ) {
833
831
exfat_err (sb , "access to deleted dentry" );
834
- return NULL ;
832
+ return - EIO ;
835
833
}
836
834
837
835
byte_offset = EXFAT_DEN_TO_B (entry );
838
836
ret = exfat_walk_fat_chain (sb , p_dir , byte_offset , & clu );
839
837
if (ret )
840
- return NULL ;
838
+ return ret ;
841
839
842
- es = kzalloc (sizeof (* es ), GFP_KERNEL );
843
- if (!es )
844
- return NULL ;
840
+ memset (es , 0 , sizeof (* es ));
845
841
es -> sb = sb ;
846
842
es -> modified = false;
847
843
@@ -859,7 +855,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
859
855
860
856
bh = sb_bread (sb , sec );
861
857
if (!bh )
862
- goto free_es ;
858
+ return - EIO ;
863
859
es -> bh [es -> num_bh ++ ] = bh ;
864
860
865
861
ep = exfat_get_dentry_cached (es , 0 );
@@ -875,8 +871,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
875
871
es -> bh = kmalloc_array (num_bh , sizeof (* es -> bh ), GFP_KERNEL );
876
872
if (!es -> bh ) {
877
873
brelse (bh );
878
- kfree (es );
879
- return NULL ;
874
+ return - ENOMEM ;
880
875
}
881
876
es -> bh [0 ] = bh ;
882
877
}
@@ -905,11 +900,11 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
905
900
if (!exfat_validate_entry (exfat_get_entry_type (ep ), & mode ))
906
901
goto free_es ;
907
902
}
908
- return es ;
903
+ return 0 ;
909
904
910
905
free_es :
911
906
exfat_free_dentry_set (es , false);
912
- return NULL ;
907
+ return - EIO ;
913
908
}
914
909
915
910
static inline void exfat_reset_empty_hint (struct exfat_hint_femp * hint_femp )
0 commit comments