ANDROID: sdcardfs: Check for private data earlier
authorDaniel Rosenberg <drosen@google.com>
Wed, 11 Apr 2018 23:19:10 +0000 (16:19 -0700)
committerDaniel Rosenberg <drosen@google.com>
Wed, 25 Apr 2018 20:40:46 +0000 (20:40 +0000)
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 <drosen@google.com>
fs/sdcardfs/dentry.c
fs/sdcardfs/lookup.c
fs/sdcardfs/main.c

index e9426a61d04a416cbf3658cc314c57d5a0f402ae..166f14b2400bff12d22df44918186b93eb91766d 100644 (file)
@@ -131,6 +131,8 @@ out:
 
 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);
index 7dab5f76896b1d30f9ce8de9a801ded38776dc60..2ff3051618820847de4e20cf136e466bfc5f6abf 100644 (file)
@@ -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;
 }
index e4fd3fbb05e69c765bf5f53173a4a662642462f5..c3120108f627feabe6b9c204529d32d5c4e497cf 100644 (file)
@@ -422,7 +422,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);