Skip to content

Commit

Permalink
Merge tag 'exfat-for-5.9-rc9' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/linkinjeon/exfat

Pull exfat fixes from Namjae Jeon:

 - Fix use of uninitialized spinlock on error path

 - Fix missing err assignment in exfat_build_inode()

* tag 'exfat-for-5.9-rc9' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat:
  exfat: fix use of uninitialized spinlock on error path
  exfat: fix pointer error checking
  • Loading branch information
torvalds committed Oct 8, 2020
2 parents 86f0a5f + 8ff006e commit b9e3aa2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
11 changes: 0 additions & 11 deletions fs/exfat/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "exfat_raw.h"
#include "exfat_fs.h"

#define EXFAT_CACHE_VALID 0
#define EXFAT_MAX_CACHE 16

struct exfat_cache {
Expand Down Expand Up @@ -61,16 +60,6 @@ void exfat_cache_shutdown(void)
kmem_cache_destroy(exfat_cachep);
}

void exfat_cache_init_inode(struct inode *inode)
{
struct exfat_inode_info *ei = EXFAT_I(inode);

spin_lock_init(&ei->cache_lru_lock);
ei->nr_caches = 0;
ei->cache_valid_id = EXFAT_CACHE_VALID + 1;
INIT_LIST_HEAD(&ei->cache_lru);
}

static inline struct exfat_cache *exfat_cache_alloc(void)
{
return kmem_cache_alloc(exfat_cachep, GFP_NOFS);
Expand Down
3 changes: 2 additions & 1 deletion fs/exfat/exfat_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ struct exfat_sb_info {
struct rcu_head rcu;
};

#define EXFAT_CACHE_VALID 0

/*
* EXFAT file system inode in-memory data
*/
Expand Down Expand Up @@ -428,7 +430,6 @@ extern const struct dentry_operations exfat_utf8_dentry_ops;
/* cache.c */
int exfat_cache_init(void);
void exfat_cache_shutdown(void);
void exfat_cache_init_inode(struct inode *inode);
void exfat_cache_inval_inode(struct inode *inode);
int exfat_get_cluster(struct inode *inode, unsigned int cluster,
unsigned int *fclus, unsigned int *dclus,
Expand Down
2 changes: 0 additions & 2 deletions fs/exfat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
ei->i_crtime = info->crtime;
inode->i_atime = info->atime;

exfat_cache_init_inode(inode);

return 0;
}

Expand Down
13 changes: 6 additions & 7 deletions fs/exfat/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,

i_pos = exfat_make_i_pos(&info);
inode = exfat_build_inode(sb, &info, i_pos);
if (IS_ERR(inode))
err = PTR_ERR_OR_ZERO(inode);
if (err)
goto unlock;

inode_inc_iversion(inode);
Expand Down Expand Up @@ -745,10 +746,9 @@ static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentry,

i_pos = exfat_make_i_pos(&info);
inode = exfat_build_inode(sb, &info, i_pos);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
err = PTR_ERR_OR_ZERO(inode);
if (err)
goto unlock;
}

i_mode = inode->i_mode;
alias = d_find_alias(inode);
Expand Down Expand Up @@ -890,10 +890,9 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)

i_pos = exfat_make_i_pos(&info);
inode = exfat_build_inode(sb, &info, i_pos);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
err = PTR_ERR_OR_ZERO(inode);
if (err)
goto unlock;
}

inode_inc_iversion(inode);
inode->i_mtime = inode->i_atime = inode->i_ctime =
Expand Down
5 changes: 4 additions & 1 deletion fs/exfat/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ static int exfat_read_root(struct inode *inode)
inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
current_time(inode);
exfat_truncate_atime(&inode->i_atime);
exfat_cache_init_inode(inode);
return 0;
}

Expand Down Expand Up @@ -763,6 +762,10 @@ static void exfat_inode_init_once(void *foo)
{
struct exfat_inode_info *ei = (struct exfat_inode_info *)foo;

spin_lock_init(&ei->cache_lru_lock);
ei->nr_caches = 0;
ei->cache_valid_id = EXFAT_CACHE_VALID + 1;
INIT_LIST_HEAD(&ei->cache_lru);
INIT_HLIST_NODE(&ei->i_hash_fat);
inode_init_once(&ei->vfs_inode);
}
Expand Down

0 comments on commit b9e3aa2

Please sign in to comment.