Skip to content

Commit

Permalink
ANDROID: sdcardfs: Check for private data earlier
Browse files Browse the repository at this point in the history
When an sdcardfs dentry is destroyed, it may not yet
have its fsdata initialized. It must be checked before
we try to access the paths in its private data.

Additionally, when cleaning up the superblock after
a failure, we don't have our sb private data, so
check for that case.

Bug: 77923821
Change-Id: I89caf6e121ed86480b42024664453fe0031bbcf3
Signed-off-by: Daniel Rosenberg <[email protected]>
  • Loading branch information
drosen-google authored and GuaiYiHu committed Apr 30, 2018
1 parent 2c74483 commit 78ceb8d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions fs/sdcardfs/dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)

static void sdcardfs_d_release(struct dentry *dentry)
{
if (!dentry || !dentry->d_fsdata)
return;
/* release and reset the lower paths */
if (has_graft_path(dentry))
sdcardfs_put_reset_orig_path(dentry);
Expand Down
2 changes: 0 additions & 2 deletions fs/sdcardfs/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ void sdcardfs_destroy_dentry_cache(void)

void free_dentry_private_data(struct dentry *dentry)
{
if (!dentry || !dentry->d_fsdata)
return;
kmem_cache_free(sdcardfs_dentry_cachep, dentry->d_fsdata);
dentry->d_fsdata = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/sdcardfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void sdcardfs_kill_sb(struct super_block *sb)
{
struct sdcardfs_sb_info *sbi;

if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
if (sb->s_magic == SDCARDFS_SUPER_MAGIC && sb->s_fs_info) {
sbi = SDCARDFS_SB(sb);
mutex_lock(&sdcardfs_super_list_lock);
list_del(&sbi->list);
Expand Down

0 comments on commit 78ceb8d

Please sign in to comment.