@@ -226,15 +226,18 @@ static inline const struct xattr_handler *f2fs_xattr_handler(int index)
226
226
}
227
227
228
228
static struct f2fs_xattr_entry * __find_xattr (void * base_addr ,
229
- void * last_base_addr , int index ,
230
- size_t len , const char * name )
229
+ void * last_base_addr , void * * last_addr ,
230
+ int index , size_t len , const char * name )
231
231
{
232
232
struct f2fs_xattr_entry * entry ;
233
233
234
234
list_for_each_xattr (entry , base_addr ) {
235
235
if ((void * )(entry ) + sizeof (__u32 ) > last_base_addr ||
236
- (void * )XATTR_NEXT_ENTRY (entry ) > last_base_addr )
236
+ (void * )XATTR_NEXT_ENTRY (entry ) > last_base_addr ) {
237
+ if (last_addr )
238
+ * last_addr = entry ;
237
239
return NULL ;
240
+ }
238
241
239
242
if (entry -> e_name_index != index )
240
243
continue ;
@@ -254,19 +257,9 @@ static struct f2fs_xattr_entry *__find_inline_xattr(struct inode *inode,
254
257
unsigned int inline_size = inline_xattr_size (inode );
255
258
void * max_addr = base_addr + inline_size ;
256
259
257
- list_for_each_xattr (entry , base_addr ) {
258
- if ((void * )entry + sizeof (__u32 ) > max_addr ||
259
- (void * )XATTR_NEXT_ENTRY (entry ) > max_addr ) {
260
- * last_addr = entry ;
261
- return NULL ;
262
- }
263
- if (entry -> e_name_index != index )
264
- continue ;
265
- if (entry -> e_name_len != len )
266
- continue ;
267
- if (!memcmp (entry -> e_name , name , len ))
268
- break ;
269
- }
260
+ entry = __find_xattr (base_addr , max_addr , last_addr , index , len , name );
261
+ if (!entry )
262
+ return NULL ;
270
263
271
264
/* inline xattr header or entry across max inline xattr size */
272
265
if (IS_XATTR_LAST_ENTRY (entry ) &&
@@ -368,7 +361,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
368
361
else
369
362
cur_addr = txattr_addr ;
370
363
371
- * xe = __find_xattr (cur_addr , last_txattr_addr , index , len , name );
364
+ * xe = __find_xattr (cur_addr , last_txattr_addr , NULL , index , len , name );
372
365
if (!* xe ) {
373
366
f2fs_err (F2FS_I_SB (inode ), "inode (%lu) has corrupted xattr" ,
374
367
inode -> i_ino );
@@ -659,7 +652,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
659
652
last_base_addr = (void * )base_addr + XATTR_SIZE (inode );
660
653
661
654
/* find entry with wanted name. */
662
- here = __find_xattr (base_addr , last_base_addr , index , len , name );
655
+ here = __find_xattr (base_addr , last_base_addr , NULL , index , len , name );
663
656
if (!here ) {
664
657
f2fs_err (F2FS_I_SB (inode ), "inode (%lu) has corrupted xattr" ,
665
658
inode -> i_ino );
0 commit comments