@@ -35,6 +35,8 @@ static LIST_HEAD(records_list);
35
35
static DEFINE_MUTEX (pstore_sb_lock );
36
36
static struct super_block * pstore_sb ;
37
37
38
+ DEFINE_FREE (pstore_iput , struct inode * , if (_T ) iput (_T ))
39
+
38
40
struct pstore_private {
39
41
struct list_head list ;
40
42
struct dentry * dentry ;
@@ -337,7 +339,7 @@ int pstore_put_backend_records(struct pstore_info *psi)
337
339
int pstore_mkfile (struct dentry * root , struct pstore_record * record )
338
340
{
339
341
struct dentry * dentry ;
340
- struct inode * inode ;
342
+ struct inode * inode __free ( pstore_iput ) = NULL ;
341
343
int rc = 0 ;
342
344
char name [PSTORE_NAMELEN ];
343
345
struct pstore_private * private , * pos ;
@@ -369,7 +371,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
369
371
370
372
private = kzalloc (sizeof (* private ), GFP_KERNEL );
371
373
if (!private )
372
- goto fail_inode ;
374
+ return - ENOMEM ;
373
375
374
376
dentry = d_alloc_name (root , name );
375
377
if (!dentry )
@@ -384,16 +386,14 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
384
386
inode_set_mtime_to_ts (inode ,
385
387
inode_set_ctime_to_ts (inode , record -> time ));
386
388
387
- d_add (dentry , inode );
389
+ d_add (dentry , no_free_ptr ( inode ) );
388
390
389
391
list_add (& private -> list , & records_list );
390
392
391
393
return 0 ;
392
394
393
395
fail_private :
394
396
free_pstore_private (private );
395
- fail_inode :
396
- iput (inode );
397
397
return rc ;
398
398
}
399
399
0 commit comments